please dont rip this site Prev Next

MsgWaitForMultipleObjects info  Overview  Group

The MsgWaitForMultipleObjects function returns when one of the following occurs:

Note that MsgWaitForMultipleObjects does not return if there is unread input of the specified type in the message queue after the thread has called a function to check the queue. This is because functions such as PeekMessage, GetMessage, WaitMessage, MsgWaitForMultipleObjects, and MsgWaitForMultipleObjectsEx check the queue and then change the state information for the queue so that the input is no longer considered new. A subsequent call to MsgWaitForMultipleObjects will not return until new input of the specified type arrives. The existing unread input is ignored.

DWORD MsgWaitForMultipleObjects(

    DWORD nCount,

// number of handles in the object handle array

    LPHANDLE pHandles,

// pointer to the object-handle array

    BOOL fWaitAll,

// wait for all or wait for one

    DWORD dwMilliseconds,

// time-out interval in milliseconds

    DWORD dwWakeMask 

// type of input events to wait for

   );

Parameters

nCount
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
Points to an array of object handles. For a list of the object types whose handles can be specified, see the following Remarks section. The array can contain handles of objects of different types.

Windows NT: The handles must have SYNCHRONIZE access.

fWaitAll
Specifies the wait type. If TRUE, the function returns when the states of all objects in the pHandles array, including input events, have been set to signaled. If FALSE, the function returns when the state of any one of the objects is set to signaled. In the latter case, the return value indicates the object whose state caused the function to return.
dwMilliseconds
Specifies the time-out interval, in milliseconds. The function returns if the interval elapses, even if the criteria specified by the fWaitAll or dwWakeMask parameter have not been met. If dwMilliseconds is 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.
dwWakeMask
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

Meaning

QS_ALLINPUT

Any message is in the queue.

QS_HOTKEY

A WM_HOTKEY 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_SYSKEYDOWN message is in the queue.

QS_MOUSE

A WM_MOUSEMOVE message or mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN, and so on).

QS_MOUSEBUTTON

A mouse-button message (WM_LBUTTONUP, WM_RBUTTONDOWN, and so on).

QS_MOUSEMOVE

A WM_MOUSEMOVE message is in the queue.

QS_PAINT

A WM_PAINT message 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_TIMER message is in the queue.

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:

Value

Meaning

WAIT_OBJECT_0 to
(WAIT_OBJECT_0 + nCount - 1)

If fWaitAll is TRUE, the return value indicates that the state of all specified objects is signaled. If fWaitAll is FALSE, the return value minus WAIT_OBJECT_0 indicates the pHandles array index of the object that satisfied the wait.

WAIT_OBJECT_0 + nCount

Input of the type specified in the dwWakeMask parameter is available in the thread’s input queue.

WAIT_ABANDONED_0 to
(WAIT_ABANDONED_0 + nCount - 1)

If fWaitAll is TRUE, 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. If fWaitAll is FALSE, the return value minus WAIT_ABANDONED_0 indicates the pHandles array index of an abandoned mutex object that satisfied the wait.

WAIT_TIMEOUT

The time-out interval elapsed and the conditions specified by the fWaitAll and dwWakeMask parameters were not satisfied.

If the function fails, the return valueis 0xFFFFFFFF. To get extended error information, call GetLastError.

Remarks

The MsgWaitForMultipleObjects function determines whether the wait criteria have been met. If the criteria have not been met, the calling thread enters an efficient wait state, using very little processor time while waiting for the conditions of the wait criteria to be met.

The function does not modify the states of the specified objects until the states of all objects have been set to signaled. For example, a mutex can be signaled, but the thread does not get ownership until the states of the other objects have also been set to signaled. In the meantime, some other thread may get ownership of the mutex, thereby setting its state to nonsignaled.

When fWaitAll is TRUE, the function’s wait is completed only when the states of all objects have been set to signaled, including the input events specified by dwWaskMask. Therefore, setting fWaitAll to TRUE prevents input from being processed until the state of all objects in the pHandles array have been set to signaled. For this reason, if you set fWaitAll to TRUE, you should use a short timeout value in dwMilliseconds. If you have a thread that creates windows waiting for all objects in the pHandles array, including input events specified by dwWakeMask, with no timeout interval, the system will deadlock. This is because threads that create windows must process messages. DDE sends message to all windows in the system. Therefore, if a thread creates windows, do not set the fWaitAll parameter to TRUE in calls to MsgWaitForMultipleObjects made from that thread.

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 count of a semaphore object is decreased by one.

The MsgWaitForMultipleObjects function can specify handles of any of the following object types in the pHandles array:

Object

Description

Change notification

The FindFirstChangeNotification function returns the handle. The state of a change notification object is set to signaled when a specified type of change occurs within a specified directory or directory tree.

Console input

The CreateFile function returns the handle when the CONIN$ value is specified, or the GetStdHandle function returns the handle. The state of the object is set to signaled when there is unread input in the console’s input buffer and nonsignaled when the input buffer is empty.

Event

The CreateEvent or OpenEvent function returns the handle. The state of an event object is set explicitly to signaled by the SetEvent or PulseEvent function. The state of a manual-reset event object must be reset explicitly to nonsignaled by the ResetEvent function. For an auto-reset event object, the wait function resets the object state to nonsignaled before returning. Event objects are also used in overlapped operations, in which the state is set by the system.

Mutex

The CreateMutex or OpenMutex function returns the handle. The state of a mutex object is signaled when it is not owned by any thread. The wait function requests ownership of the mutex for the calling thread, changing the mutex state to nonsignaled when ownership is granted.

Process

The CreateProcess or OpenProcess function returns the handle. The state of a process object is set to signaled when the process terminates.

Semaphore

The CreateSemaphore or OpenSemaphore function returns the handle. A semaphore object maintains a count between zero and the maximum count specified during its creation. Its state is set to signaled when its count is greater than zero and nonsignaled when its count is zero. If the current state of the semaphore is signaled, the wait function decreases the count by one.

Thread

The CreateProcess, CreateThread, or CreateRemoteThread function returns the handle. The state of a thread object is set to signaled when the thread terminates.

Timer

The CreateWaitableTimer or OpenWaitableTimer function returns the handle. Activate the timer by calling the SetWaitableTimer function. The state of an active timer is set to signaled when it reaches its due time. You can deactivate the timer by calling the CancelWaitableTimer function.

In some circumstances, you can specify a handle of a file, named pipe, or communications device as a synchronization object in lpHandles. However, their use for this purpose is discouraged.

See Also

CancelWaitableTimer, CreateEvent, CreateFile, CreateMutex, CreateProcess, CreateRemoteThread, CreateSemaphore, CreateThread, FindFirstChangeNotification, GetStdHandle, MsgWaitForMultipleObjectsEx OpenEvent, OpenMutex, OpenProcess, OpenSemaphore, OpenWaitableTimer, PulseEvent, ResetEvent, SetEvent

 


file: /Techref/os/win/api/win32/func/src/f57_19.htm, 16KB, , updated: 2000/4/7 11:19, local time: 2024/11/25 14:54,
TOP NEW HELP FIND: 
3.139.98.10:LOG IN

 ©2024 These pages are served without commercial sponsorship. (No popup ads, etc...).Bandwidth abuse increases hosting cost forcing sponsorship or shutdown. This server aggressively defends against automated copying for any reason including offline viewing, duplication, etc... Please respect this requirement and DO NOT RIP THIS SITE. Questions?
Please DO link to this page! Digg it! / MAKE!

<A HREF="http://techref.massmind.org/Techref/os/win/api/win32/func/src/f57_19.htm"> MsgWaitForMultipleObjects</A>

After you find an appropriate page, you are invited to your to this massmind site! (posts will be visible only to you before review) Just type a nice message (short messages are blocked as spam) in the box and press the Post button. (HTML welcomed, but not the <A tag: Instead, use the link box to link to another page. A tutorial is available Members can login to post directly, become page editors, and be credited for their posts.


Link? Put it here: 
if you want a response, please enter your email address: 
Attn spammers: All posts are reviewed before being made visible to anyone other than the poster.
Did you find what you needed?

 

Welcome to massmind.org!

 

Welcome to techref.massmind.org!

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

  .