dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosSleep (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSPROCESS
 
USHORT DosSleep(ulTime)
ULONG ulTime;    /* number of milliseconds to wait */
 
The DosSleep function causes the current thread to wait for a specified
interval or, if the specified interval is zero, to give up the remainder of
the current time slice.
 
The DosSleep function is a family API function.
 
Parameter  Description
────────────────────────────────────────────────────────────────────────────
 
ulTime     Specifies the number of milliseconds that the thread waits. This
           value is rounded up to the next clock tick.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be the following:
 
     ERROR_TS_WAKEUP
 
Comments
 
The time the thread waits can be different from the specified time by a
clock tick or two, depending on the execution status of the other threads
running in the system. If the specified interval is zero, the process
forgoes the remainder of its CPU time slice but is scheduled normally for
its next time slice. When a process continues after suspension, its
scheduled execution time could be delayed by hardware interrupts or by
another thread running at a higher priority. If the time interval is not
zero it is given in milliseconds, which are rounded up to the resolution of
the scheduler clock. The DosSleep function should not be substituted for a
real-time clock, because the rounding of the wait interval will cause
inaccuracies to accumulate.
 
Example
 
This example sets up a loop that waits for one second and then retrieves the
time and date:
 
DATETIME date;
for (;;) {
    DosSleep(1000L);         /* waits for one second        */
    DosGetDateTime(&date);   /* retrieves the time and date */
    .
    .
    .
}
 
See Also
 
DosGetInfoSeg, DosTimerAsync, DosTimerStart