sasjaa
asked on
Problem with the message pump hanging
I have a very strange problem. I am working with an application that
uses many different threads. At some point I seem to get into a
situation where there are no threads to pump the message queue. The code
in question create an event and posts a WM_USER style message to the
window queue and then does a WaitForSingleObject(). The message pump is
supposed to see the message and post the event to cause the wait to
finish. The problem appears to be that the thread that is supposed to be
pumping is the one waiting. I tried using WaitForMultipleObjects() and
dispatching the messages myself but that also doesn't seem to work.
I am looking for any other clues that prople might be able to give me.
The purpose of this logic is to insure that the message queue is empty
before killing the window. The processing must be synchonous. I don't think I can allow the window to
go down asynchronously
uses many different threads. At some point I seem to get into a
situation where there are no threads to pump the message queue. The code
in question create an event and posts a WM_USER style message to the
window queue and then does a WaitForSingleObject(). The message pump is
supposed to see the message and post the event to cause the wait to
finish. The problem appears to be that the thread that is supposed to be
pumping is the one waiting. I tried using WaitForMultipleObjects() and
dispatching the messages myself but that also doesn't seem to work.
I am looking for any other clues that prople might be able to give me.
The purpose of this logic is to insure that the message queue is empty
before killing the window. The processing must be synchonous. I don't think I can allow the window to
go down asynchronously
ASKER
I don't see how a Mutex can help. A window destroy request comes in and we need to make sure that there are no pending messages in the queue for this window before we delete the object. Microsoft documentation clearly states that a CEvent should be used if we must wait for something else to happen before continuing. The problem is that we are waiting on messages and there seems to be nothing to process the messages.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
In any case, I can't be sure about this solution without seeing code or without a general outline of what's happening, so post more if you need more.