Microsoft Windows CE 3.0  

MsgWaitForMultipleObjectsEx

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 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. This function does not return if there is unread input of the specified type in the queue. It returns only when new input arrives.

DWORD MsgWaitForMultipleObjectsEx(
DWORD
nCount
,
LPHANDLE
pHandles
,
DWORD
dwMilliseconds
,
DWORD
dwWakeMask
,
DWORD
dwFlags
);

Parameters

nCount
[in] Specifies the number of object handles in the array pointed to by pHandles. The maximum number of object handles is MAXIMUM_WAIT_OBJECTS minus one.
pHandles
[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.
dwMilliseconds
[in] Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the conditions specified by the dwWakeMaskand dwFlagsparameters are not met. If dwMillisecondsis zero, the function tests the states of the specified objects and returns immediately. If dwMillisecondsis INFINITE, the function's time-out interval never elapses.
dwWakeMask
[in] Specifies 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:
Value Description
QS_ALLEVENTS An input, WM_TIMER, WM_PAINT, WM_HOTKEY, or posted message is in the queue.
QS_ALLINPUT Any message is in the queue.
QS_INPUT An input message is in the queue.
QS_KEY A WM_KEYUP, WM_KEYDOWN, WM_SYSKEYUP, or WM_SYSKEYDOWNmessage is in the queue.
QS_MOUSE A WM_MOUSEMOVEmessage or mouse-button message ( WM_LBUTTONUP, WM_LBUTTONDOWN, and so on) is in the queue.
QS_MOUSEBUTTON A mouse-button message ( WM_LBUTTONUP, WM_LBUTTONDOWN, and so on) is in the queue.
QS_MOUSEMOVE A WM_MOUSEMOVEmessage is in the queue.
QS_PAINT A WM_PAINTmessage is in the queue.
QS_POSTMESSAGE A posted message (other than those just listed) is in the queue.
QS_SENDMESSAGE A message sent by another thread or application is in the queue.
QS_TIMER A WM_TIMERmessage is in the queue.
dwFlags
[in] Specifies the wait type. It can be any combination of the following values:
Value Description
0 The function returns when any one of the objects is signaled. The return value indicates the object whose state caused the function to return.
MWMO_INPUTAVAILABLE The function returns if input exists for the queue, even if the input has been seen (but not removed) using a call to another function, such as PeekMessage.

Return Values

If the function succeeds, the return value indicates the event that caused the function to return. The 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 pHandlesarray index of the object that caused the function to return.
WAIT_OBJECT_0 + nCount
New input of the type specified in the dwWakeMaskparameter is available in the thread's input queue. Functions such as PeekMessageand GetMessagemark messages in the queue as old messages. Therefore, after you call one of these functions, a subsequent call to MsgWaitForMultipleObjectsExwill 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, MsgWaitForMultipleObjectsExcan return even though no appropriate input is available and even if dwWaitMaskis set to 0. If this occurs, call PeekMessageor GetMessageto process the system event before trying the call to MsgWaitForMultipleObjectsExagain.

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 pHandlesarray index of an abandoned mutex object that caused the function to return.
WAIT_IO_COMPLETION
The wait was ended by a user-mode asynchronous procedure call (APC) queued to the thread.
WAIT_TIMEOUT
The time-out interval elapsed, but the conditions specified by the dwFlagsand dwWakeMaskparameters were not met.

0xFFFFFFFF indicates failure. To get extended error information, call GetLastError.

Remarks

The MsgWaitForMultipleObjectsExfunction determines whether the conditions specified by dwWakeMaskand dwFlagshave been met. If the conditions have not been met, the calling thread enters an efficient wait state. 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 returning, a wait function modifies the state of some types of synchronization objects. 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. When dwFlagsis zero, and multiple objects are in the signaled state, the function chooses one of the objects to satisfy the wait; the states of the objects not selected are unaffected.

The MsgWaitForMultipleObjectsExfunction copies the handle table, adds to it the message queue event, and calls WaitForMultipleObjects.

The MsgWaitForMultipleObjectsExfunction can specify handles of any of the following object types in the pHandlesarray:

  • Event
  • Mutex
  • Critical section
  • Semaphore
  • Process
  • Thread

    The QS_POSTMESSAGE flag is cleared when you call GetMessageor PeekMessage, whether or not you are filtering messages.

    Requirements

    Runs on Versions Defined in Include Link to
    Windows CE OS 2.0 and later Winbase.h   Msgque.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.