DosWaitThread is used to wait for termination of threads within a process. It is usually used so that thread resources (for example, the stack) can be recovered when a thread ends. DosWaitThread waits on any thread within the current process, or on a specific thread within the process, based on the ptid parameter's contents. option allows the caller the option of waiting until a thread ends, or getting immediate return and status. If no thread has ended and the DCWW_NOWAIT option is specified, the ptid field is preserved.

If DosWaitThread is called with the input ptid set to the current thread (the thread attempts to wait on its own termination), the ERROR_INVALID_THREADID error code is returned. ERROR_INVALID_THREADID is also returned if a caller attempts to wait on the termination of the thread with a ptid of 1.


[Back] [Next]