MsgWaitForMultipleObjectsEx (Compact 2013)
This function returns when either one or all of the specified objects are in the signaled state, an I/O completion routine or asynchronous procedure call (APC) is queued to the thread, or the time-out interval elapses.
DWORD MsgWaitForMultipleObjectsEx( DWORD nCount, LPHANDLE pHandles, DWORD dwMilliseconds, DWORD dwWakeMask, DWORD dwFlags );
[in] Number of object handles in the array that is pointed to by pHandles. The maximum number of object handles is (MAXIMUM_WAIT_OBJECTS - 1).
[in] Pointer to an array of object handles. For a list of the object types whose handles you can specify, see the Remarks section later in this topic. The array can contain handles to multiple types of objects.
[in] Time-out interval, in milliseconds. The function returns if the interval elapses, even if the conditions specified by the dwWakeMask and dwFlags parameters are not met. If dwMilliseconds is 0 (zero), the function tests the states of the specified objects and returns immediately. If dwMilliseconds is INFINITE, the function's time-out interval never elapses.
[in] Input types for which an input event object handle will be added to the array of object handles. This parameter can be any combination of the following values.
Either an input message, a posted message, or a WM_TIMER, WM_PAINT, or WM_HOTKEY message is in the queue.
Any message is in the queue.
An input message, such as a mouse or keyboard message, is in the queue.
A mouse-button message (WM_LBUTTONUP, WM_LBUTTONDOWN, and so on) is in the queue.
A WM_MOUSEMOVE message is in the queue.
A WM_PAINT message is in the queue.
A posted message (other than those listed above) is in the queue.
A message sent by another thread or application is in the queue.
A WM_TIMER message is in the queue.
[in] Wait type. It can be any combination of the following values.
The function returns when any one of the objects is signaled. The return value indicates the object whose state caused the function to return.
The function returns if input exists for the queue, even if the input has been seen (but not removed) by using a call to another function, such as PeekMessage.
The function returns when all objects in the pHandles array are signaled and an input event has been received, concurrently.
If the function succeeds, the return value indicates the event that caused the function to return. A successful return value is one of the following:
- WAIT_OBJECT_0 to (WAIT_OBJECT_0 + nCount-1)
If the MWMO_WAITALL flag is used, the return value indicates that the state of all specified objects is signaled. Otherwise, the return value minus WAIT_OBJECT_0 indicates the pHandles array index of the object that caused the function to return.
WAIT_OBJECT_0 + nCount
New input of the type specified in the dwWakeMask parameter is available in the thread's input queue. Functions such as PeekMessage and GetMessage mark messages in the queue as old messages. Therefore, after you call one of these functions, a subsequent call to MsgWaitForMultipleObjectsEx will not return until new input of the specified type arrives.
This value is also returned upon the occurrence of a system event that requires the thread's action, such as foreground activation. Therefore, MsgWaitForMultipleObjectsEx can return even though no appropriate input is available and even if dwWaitMask is set to 0. If this occurs, call PeekMessage or GetMessage to process the system event before trying the call to MsgWaitForMultipleObjectsEx again.
- WAIT_ABANDONED_0 to (WAIT_ABANDONED_0 + nCount-1)
If the MWMO_WAITALL flag is used, the return value indicates that the state of all specified objects is signaled and at least one of the objects is an abandoned mutex object. Otherwise, the return value minus WAIT_ABANDONED_0 indicates the pHandles array index of an abandoned mutex object that caused the function to return.
The wait was ended by a user-mode asynchronous procedure call (APC) queued to the thread.
The time-out interval elapsed, but the conditions specified by the dwFlags and dwWakeMask parameters were not met.
0xFFFFFFFF indicates failure. To get extended error information, call GetLastError.
The MsgWaitForMultipleObjectsEx function determines whether the conditions specified by dwWakeMask and dwFlags have been met. If the conditions have not been met, the calling thread enters a state in which it waits for the conditions to be met. The thread uses very little processor time while waiting for one of the conditions to be met or for the time-out interval to elapse.
Before this function returns, the system must modify the state of some type of synchronization object. Modification occurs only for the object or objects whose signaled state caused the function to return. For example, the system decreases the count of a semaphore object by one. For more information, see the documentation for the individual synchronization objects.
This function does not return if there is unread input of the specified type in the queue. It returns only when new input arrives.
The MsgWaitForMultipleObjectsEx function copies the handle table, adds to it the message queue event, and calls WaitForMultipleObjects.
The MsgWaitForMultipleObjectsEx function can specify handles of any of the following object types in the pHandles array:
- Critical section
The QS_POSTMESSAGE flag is cleared when you call GetMessage or PeekMessage, whether or not you are filtering messages.