Important: |
---|
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist. |
This function returns when the specified object is in the signaled state or when the time-out interval elapses.
DWORD WaitForSingleObject( HANDLE hHandle , DWORD dwMilliseconds );
Parameters
Return Values
If the function succeeds, the return value indicates the event that caused the function to return. This value can be one of the following.
Value | Description |
---|---|
WAIT_ABANDONED | The specified object is a mutex object that was not released by the thread that owned the mutex object before the owning thread terminated. Ownership of the mutex object is granted to the calling thread, and the mutex is set to nonsignaled. |
WAIT_OBJECT_0 | The state of the specified object is signaled. |
WAIT_TIMEOUT | The time-out interval elapsed, and the object's state is nonsignaled. |
WAIT_FAILED indicates failure. Waiting on an invalid handle causes WaitForSingleObjectto return WAIT_FAILED.
To get extended error information, call GetLastError.
Remarks
Windows CE versions 1.0 through 2.12 does not support waiting for semaphores, change notification objects, input, and timers. Windows 3.0 and later supports waiting for semaphores.
For Windows CE versions 1.0 and 1.01, this function cannot wait on process or thread handles.
The WaitForSingleObjectfunction checks the current state of the specified object. If the object's state is nonsignaled, the calling thread enters an efficient wait state. The thread consumes very little processor time while waiting for the object state to become signaled or the time-out interval to elapse.
The time-out value needs to be a positive number between 0 and 0x7FFFFFFF. The maximum time-out value not equal to infinity is 0x7FFFFFFF. The infinite time-out value is 0xFFFFFFFF. Any time-out value between 0x7FFFFFFF and 0xFFFFFFFF—that is, values from 0xF0000000 through 0xFFFFFFFE—is equivalent to 0x7FFFFFFF. If you need a bigger time-out value than the maximum of 0x7FFFFFFF, use the value for infinity (0xFFFFFFFF).
Before returning, a wait function modifies the state of some types of synchronization objects. Modification occurs only for the object whose signaled state caused the function to return. For example, the count of a semaphore object is decreased by one.
The WaitForSingleObjectfunction can wait for the following objects:
Use caution when calling the wait functions and code that directly or indirectly creates windows. If a thread creates any windows, it must process messages. Message broadcasts are sent to all windows in the system. A thread that uses a wait function with no time-out interval may cause the system to become deadlocked. Two examples of code that indirectly creates windows are DDE and COM CoInitialize. Therefore, if you have a thread that creates windows, use MsgWaitForMultipleObjectsor MsgWaitForMultipleObjectsEx, rather than WaitForSingleObject.
Requirements
Runs on | Versions | Defined in | Include | Link to |
---|---|---|---|---|
Windows CE OS | 1.0 and later | Winbase.h | Coredll.lib |
Note This API is part of the complete Windows CE OS package as provided by Microsoft. The functionality of a particular platform is determined by the original equipment manufacturer (OEM) and some devices may not support this API.
See Also
CreateEvent, CreateFile, PulseEvent, ResetEvent, SetEvent, Sleep