Re: MsgWaitForMultipleObjects
- From: "nly" <nlyee2001@xxxxxxxxx>
- Date: Mon, 5 Sep 2005 17:06:58 -0700
William DePalo [MVP VC++] <willd.no.spam@xxxxxxxx> wrote in message
news:ukZcNgRsFHA.3504@xxxxxxxxxxxxxxxxxxxxxxx
> "nly" <nlyee2001@xxxxxxxxx> wrote in message
> news:egEcr$QsFHA.4044@xxxxxxxxxxxxxxxxxxxxxxx
> > In the sample usage of MsgWaitForMultipleObjects at:
> >
> >
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/bas
> > e/waiting_in_a_message_loop.asp
> >
> > what confusing is the part below:
> >
> > // Read all of the messages in this next loop,
> > // removing each message as we read it.
> > while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
> >
> >
> > // If it is a quit message, exit.
> > if (msg.message == WM_QUIT)
> > return 1;
> > // Otherwise, dispatch the message.
> > DispatchMessage(&msg);
> > } // End of PeekMessage while loop.
> >
> > // Wait for any message sent or posted to this queue
> > // or for one of the passed h.andles be set to signaled.
> > result = MsgWaitForMultipleObjects(cObjects, lphObjects,
> > FALSE, INFINITE, QS_ALLINPUT);
> >
> > PeekMessage() is peeking on ths same queue as
MsgWaitForMultipleObjects()
> > waits on, correct?
> >
> > MsgWaitForMultipleObjects() isn't waiting "...for any message sent or
> > posted
> > to this queue", correct?
> >
> > Thnaks in advance!
> >
> >
>
> For each iteration of the loop, first the message queue is checked. If
there
> are any messages in the queue they are removed.
>
> Once the queue is drained then the code waits on any of the objects
> specified in the call to MsgWaitForMultipleObjects() to be signaled OR the
> arrival of the next message, whichever happens first.
>
> Then the loop repeats until a WM_QUIT message is encountered.
>
> Regards,
> Will
>
>
Thanks! What if don't remove the messages in the queue? Does this mean that
MsgWaitForMultipleObjects() will never be signaled at all?
Why is it necessary that for MsgWaitForMultipleObjects() to be signaled, all
messages in the queue have to be removed?
Will the queued message(s) block MsgWaitForMultipleObjects() to be signaled?
.
- Follow-Ups:
- Re: MsgWaitForMultipleObjects
- From: William DePalo [MVP VC++]
- Re: MsgWaitForMultipleObjects
- References:
- Re: MsgWaitForMultipleObjects
- From: William DePalo [MVP VC++]
- Re: MsgWaitForMultipleObjects
- Prev by Date: Re: Windows Function definitions
- Next by Date: Re: URLDownloadToFile
- Previous by thread: Re: MsgWaitForMultipleObjects
- Next by thread: Re: MsgWaitForMultipleObjects
- Index(es):
Relevant Pages
|