[fpc-pascal]dos approx delay fn that releases cpu

Gabor DEAK JAHN djg at tramontana.co.hu
Tue May 8 22:36:59 CEST 2001


At 5/8/01 12:35 PM, you wrote:

John,

 > interupts and doing a dos idle in between (believe that releases cpu in
 > NT/w2000???).  Anyone know exactly the code for that would look...?

NT (and 2000) have a function specifically for this purpose,
WaitForSingleObject (Sleep is also available but GUI programs should avoid
using Sleep). This function returns if either the object is waits for
becomes signaled or the timeout interval elapses. We can simply use our own
thread as the object to be waited for. It will remain non-signaled while it
runs, thus the timeout will prevail. The thread stays in a very efficient
wait state during the delay, consuming very little processor time. The
actual call would be:

WaitForSingleObject (GetCurrentThread, DelayMS);


Bye,
    Gábor

-------------------------------------------------------------------
Gabor DEAK JAHN -- Budapest, Hungary.
E-mail: djg at tramontana.co.hu





More information about the fpc-pascal mailing list