Suspending the Current Thread

You can temporarily suspend the execution of the current thread for a set amount of time by using DosSleep. This function suspends execution of the thread for the specified number of milliseconds. DosSleep is useful when you need to delay the execution of a task. For example, you can use DosSleep to delay a response when the user presses a DIRECTION key. The delay provides the user with enough time to observe the results and release the key.

The following code fragment uses DosSleep to suspend execution of a thread for 1000 milliseconds (1 second):

    #define INCL_DOSPROCESS       /* Process and thread values */
    #include <os2.h>

    DosSleep(1000);


[Back: Changing the Priority of a Thread]
[Next: Suspending and Resuming Execution of a Thread]