Article View: borland.public.cppbuilder.nativeapi
Article #8819Re: Wait Functions - Sleep
From: Mark Jacobs
Date: Mon, 20 Sep 2004 09:19
Date: Mon, 20 Sep 2004 09:19
40 lines
2275 bytes
2275 bytes
I use a different solution, derived from the Win32 API, which is accurate to
about 5 milliseconds. Here it is :-
void mjdelay(unsigned int msecs)
{
unsigned int nw;
timeBeginPeriod(5); nw=timeGetTime();
do { Sleep(5); Application->ProcessMessages();} while
(timeGetTime()-nw<msecs);
timeEndPeriod(5);
}
--
Mark Jacobs
DK Computing
http://www.dkcomputing.co.uk
markj atty critical dotty co dotty uk
"McKool" <kenethw@peak-system.com> wrote in message
news:414e8404$2@newsgroups.borland.com...
| Hello, i need to count in milliseconds, but that count must to be exact.
| I'm using the Sleep function but is not always the same result....
|
| InitTime = GetTickCount();
| Sleep(25);
| MittleTime = GetTickCount() - InitTime;
|
| Hier MittleTime is 3 or 4 times 31 or 32 (i assumed that +/- 7 millis is
| what the function need to get and give the time)... and some oder times 15
| or 16 (so, less time than the specified ni the Sleep function).
|
| what can i do to get always 25 ml of delay? I read something about
| Multimedia timers... can i get with it the right timing ?
| --
| Keneth Wagner.
Technical Details
Message-ID:
<414ea078$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<414e8404$2@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,e777b9375f8aeb3 X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit Reply-To: "Mark Jacobs" <markj atty critical dotty co dotty uk> From: "Mark Jacobs" <markj atty critical dotty co dotty uk> Newsgroups: borland.public.cppbuilder.nativeapi References: <414e8404$2@newsgroups.borland.com> Subject: Re: Wait Functions - Sleep Date: Mon, 20 Sep 2004 10:19:05 +0100 Lines: 42 Organization: DK Computing X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1437 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1441 NNTP-Posting-Host: 81.144.157.8 Message-ID: <414ea078$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1095671928 81.144.157.8 (20 Sep 2004 02:18:48 -0700) Path: arc1-ca.pugleaf.net!g2news1.google.com!news2.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!newshosting.com!nx01.iad01.newshosting.com!newsfeed.icl.net!newsfeed.fjserv.net!news-FFM2.ecrc.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail