Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!mit-eddie!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!ruuinf!prisma!karel From: karel@prisma.cv.ruu.nl (Karel Zuiderveld) Newsgroups: comp.windows.ms.programmer Subject: Re: Using a timer to "sleep" Message-ID: Date: 20 Nov 90 21:08:29 GMT References: <13796@june.cs.washington.edu> Organization: University of Utrecht, 3D Computer Vision The Netherlands Lines: 31 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? > Yes, there is a very easy way to do it. The function DWORD GetTickCount() returns the number of milliseconds that have elpased since the system was started. A windows sleep function can very easily be coded: 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. The WM_TIMER approach should also work BTW. Karel -- Karel Zuiderveld E-mail: karel@cv.ruu.nl 3D Computer Vision - Room E.02.222 Tel: (31-30) 506682/507772 Academisch Ziekenhuis Utrecht Fax: (31-30) 513399 Heidelberglaan 100, 3584 CX Utrecht, The Netherlands