🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.windows.ms.programmer
Article #663

Re: Using a timer to "sleep"

#663
From: Karel Zuiderveld
Date: Tue, 20 Nov 1990 21:08
31 lines
1467 bytes
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
Technical Details
Message-ID: <karel.659135309@prisma>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!wuarchive!mit-eddie!bloom-beacon!eru!hagbard!sunic!mcsun!hp4nl!ruuinf!prisma!karel
References: <13796@june.cs.washington.edu>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!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: <karel.659135309@prisma>
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