PeekMsg/MsgWaitForMultipleObjects question

Joerg-Cyril.Hoehle at Joerg-Cyril.Hoehle at
Wed Feb 24 03:14:45 CST 2010


Alexandre wrote:
>Message waiting functions only return for new input. You need to make
>sure the queue is empty before waiting.

Actually, now that I believe I understand the issue, I'd rephrase it
differently: The queue need not be empty (a message might have
arrived 1 microsecond before the call to MsgWaitFor*).  The key
issue is that once you start to call PeekMessage or GetMessage, you
must empty the queue with these functions before calling Wait again,
because all messages present in the queue at Get/PeekMessage
time will be marked "not new" (my understanding now of MSDN).

for(;;) { PeekMessage(REMOVE)/*=pick 1*/; Wait(); }
will timeout/hang because of this when 2 messages arrive.
Exactly that happened to my code.

 Jörg Höhle

More information about the wine-devel mailing list