Article View: borland.public.cppbuilder.nativeapi
Article #9594Re: Sleep() funtion in XP
From: Martin Nijhoff
Date: Tue, 22 Jun 2004 08:24
Date: Tue, 22 Jun 2004 08:24
16 lines
1533 bytes
1533 bytes
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
Technical Details
Message-ID:
<40d7ecf1$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailReferences:
<40d7dda3@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,78dca2a71f1a0ab4 X-Google-Attributes: gid10cc67,public From: "Martin Nijhoff" <dont@mail.me> Newsgroups: borland.public.cppbuilder.nativeapi References: <40d7dda3@newsgroups.borland.com> Subject: Re: Sleep() funtion in XP Date: Tue, 22 Jun 2004 10:24:23 +0200 Lines: 18 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.100.129.156 Message-ID: <40d7ecf1$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1087892721 80.100.129.156 (22 Jun 2004 01:25:21 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!elnk-atl-nf1!newsfeed.earthlink.net!newshosting.com!nx02.iad01.newshosting.com!203.109.252.33.MISMATCH!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail