Article View: borland.public.cppbuilder.nativeapi
Article #9596Re: Sleep() funtion in XP
From: Francisco Villa
Date: Tue, 22 Jun 2004 08:35
Date: Tue, 22 Jun 2004 08:35
43 lines
1999 bytes
1999 bytes
"Martin Nijhoff" <dont@mail.me> escribi๏ฟฝ en el mensaje
news:40d7ecf1$1@newsgroups.borland.com...
> Hi Francisco,
>
> When your thread calls Sleep(), it suspends execution of your thread for
the
> specified interval so that another thread can resume execution. However,
> there is no guarantee that your thread is resumed *exactly* at the moment
> the interval expires, especially when you call Sleep() with a small
interval
> value (3 milliseconds in your case).
>
> You could try the following code to work around this:
>
> MyPort->Write(myByte);
> for (DWORD StartTime = GetTickCount(); GetTickCount() - StartTime < 3; );
>
> Hope this helps,
>
> Martin
>
>
Oooops . I forget to tell that i tried it too with this version of Sleep.
void SleepB (DWORD t)
{
DWORD StartTime =GetTickCount();
n=0;
while (GetTickCount()- StartTime < t)
{
n++;
}
}
But It DELAYS 15 ms or 16 ms too!?!?
I undersatand that the thread suspend execution but there is much diference.
However this method consumes too much CPU %.
Technical Details
Message-ID:
<40d7f263@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<40d7dda3@newsgroups.borland.com> <40d7ecf1$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII X-Google-Thread: 10cc67,78dca2a71f1a0ab4 X-Google-Attributes: gid10cc67,public From: "Francisco Villa" <nospam_francisco_destel@hotmail.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <40d7dda3@newsgroups.borland.com> <40d7ecf1$1@newsgroups.borland.com> Subject: Re: Sleep() funtion in XP Date: Tue, 22 Jun 2004 10:35:53 +0200 Lines: 47 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 NNTP-Posting-Host: 80.33.64.150 Message-ID: <40d7f263@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1087894115 80.33.64.150 (22 Jun 2004 01:48:35 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!tiscali!newsfeed1.ip.tiscali.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail