The arguments to the functions are:

nCount [in]

The maximum number of object handles is MAXIMUM_WAIT_OBJECTS minus one.

pHandles [in]

The array can contain handles to multiple types of objects. It may not contain multiple copies of the same handle.

If one of these handles is closed while the wait is still pending, the function’s behavior is undefined.


The function either waits for dwMilliseconds or until the object values

dwWakeMask [in]

The input types for which an input event object handle will be added to the array of object handles. T


Let us assume that we have a thread named as ‘thread1’. The thread does some task and needs two values for further proceedings. Let the value required by this thread be processed by another two threads, say named as ‘threadN’ and ‘threadN+1’. Now thread1 has to wait until the values required [ Eg: Object A and Object B ] are filled by threads ‘threadN’ and ‘threadN+1’.

By using MsgWaitForMultipleObjectsEx, we can achieve this. This function makes the execution wait until the objects A and B are received /filled. If values are not filled within ‘dwMilliseconds’, the wait for object stops and the execution continues sequentially.

We can think of  MsgWaitForMultipleObjectsEx as an asynchronous mechanism. let us consider a scenario where we have a UI thread and logic processing thread, executing concurrently. Then we can display a busy icon in the UI until the logic thread manipulates the data values to be rendered on the UI. In this situation we can assume that the function MsgWaitForMultipleObjectsEx is placed in logic thread and it is waiting for threadN and threadN+1 to supply values in Objects A and B, The communication between the UI component and the logic procesing unit can occur asynchronusly. Wehn value is obtained from threadN and threadN+1 , the waiting process terminates and the object values can be rendered on UI.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s