Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!odi!ed From: ed@odi.com (Ed Schwalenberg) Newsgroups: comp.windows.ms.programmer Subject: Re: Using a timer to "sleep" Message-ID: <1990Nov23.192305.4711@odi.com> Date: 23 Nov 90 19:23:05 GMT References: <13796@june.cs.washington.edu> Organization: Object Design, Inc. Lines: 22 In-Reply-To: karel@prisma.cv.ruu.nl's message of 20 Nov 90 21:08:29 GMT In article karel@prisma.cv.ruu.nl (Karel Zuiderveld) writes: In <13796@june.cs.washington.edu> goble@wolf.cs.washington.edu (Brian Goble) writes: >Is there a windows function or an MS C >function (like Turbo C's "sleep()") that will do a delay? > VOID FAR PASCAL wsleep(int iNrSeconds) { DWORD lCountStop = GetTickCount() + 1000L * (DWORD) iNrSeconds; while (GetTickCount() < lCountStop); } Of course there is one but with this approach: all CPU power is spend in that loop. while (GetTickCount() < lCountStop) Yield(); lets other Windows processes run while you're sleeping. Even better is to integrate the sleepiness with your program's message loop; see the documentation on PeekMessage.