You can see : Examining a Message Queue
Empty the Message Queue in Windows API
I am using Windows api PostThreadMessage to add the message in one thread and GetMessage the message to retrieve the message .From MSDN docs it is clear that Message Queue is limited to 10,000 message . But I am unable to test it. As I want to test it before 5,000 message . I have not find any API to check the message Queue .
What I tried: res = PostThreadMessage . If ret is 0 i.e post thread fail and using GetLastError() it get the error message .
But I want to check before the PostThreadMessage that if Message Queue Empty or full ?
If it full how to Empty the Message Queue.
Windows development | Windows API - Win32
2 answers
Sort by: Most helpful
-
-
RLWA32 49,536 Reputation points
2021-07-17T09:04:08.96+00:00 What purpose is served by seeing if the message queue of the target thread is full?
The posting thread must handle the situation if the attempt to post a message to the Target thread cannot be accomplished regardless of whether the reason is because postthreadmessage failed or was not attempted because the message queue is already full.
I suggest that you determine the reason why the Target thread is not pumping messages with enough frequency to prevent the 10,000 message limit from being reached.