[Toc][Index]

DosSleep


Bindings:  C, MASM 

This call suspends the current thread for a specified time.  If the 
requested interval is 0, the call gives up the remainder of the current 
time slice. 
 DosSleep    (TimeInterval) 
 
 TimeInterval (ULONG) - input 
    Time interval in milliseconds until the thread is awakened. 
 rc (USHORT) - return 
    Return code descriptions are: 
    0         NO_ERROR 
    322       ERROR_TS_WAKEUP 
 
 Remarks 
 DosSleep suspends the current thread for the specified time period.  The 
 actual time it is asleep may be off by a clock tick or two, depending on 
 the execution status of other threads running in the system. 
 If the time is 0, the thread gives up the remainder of the current time 
 slice and allows any other ready threads of equal priority to run with 
 the current thread for its next slice. Because the amount of sleep time 
 specified is 0, an immediate return with 0 delay is made if no other 
 ready thread is found. However, DosSleep does not yield to a thread of 
 lower priority. 
 If the time is non-0, the time is rounded up to the resolution of the 
 scheduler clock. 
 If DosSleep is used to regularly poll an external source to determine the 
 occurrence of some event, a time equal to the longest response interval 
 should be used. 
 For short time intervals, the rounding-up process combined with the 
 thread priority interactions may cause a sleeping interval to be longer 
 than requested.  Also, when a process completes sleeping, it is scheduled 
 for execution.  But that execution could be delayed by hardware 
 interrupts or by another thread running at a higher priority.  A program 
 should not use the DosSleep call as a substitute for a real-time clock 
 because rounding of the sleep interval causes cumulative errors. 
 Asynchronous timers can be started with DosTimerAsync and  DosTimerStart. 
 DosTimerAsync starts a one-shot asynchronous timer, and DosTimerStart 
 starts a periodic interval timer.  DosTimerStop is issued to stop these 
 timers. 
 Note:  To ensure optimum performance, you should not use DosSleep in a 
        single-thread Presentation Manager application. See WinStartTimer. 
        
 
 Family API Considerations 
 Some options operate differently in the DOS mode than in OS/2 mode. 
  Therefore, the following restrictions apply to DosSleep when coding in 
 DOS mode: 
 o DosSleep accuracy can be in error by 0.5%. 
 o DosSleep can degrade system performance of non-foreground program 
   operations when DOS mode is in foreground. 
 

Created using Inf-PHP v.2 (c) 2003 Yuri Prokushev
Created using Inf-HTML v.0.9b (c) 1995 Peter Childs