Re: Out of Memory Error: MultiThreading Problem?
I have an OnGotMsg handler in my GUI thread that handles incoming
messages from another application. These msgs take place every second
or so, and are passed on to another class which processes the message
and then reports this back to the GUI thread.
****
Define how this is done. How do you mean "passed on"? If you are doing a call, and the
call is from a message handler, the message pump is blocked until the control returns from
the call and therefore the handler returns to DispatchMessage. You are using vague terms
like "passed on" and "reports back" without giving precise details of the implementation.
****>However, it does so
Sorry, the "passed on" is a call as shown below:
LONG MyDlg::OnGotMsgFromApp(WPARAM wp, LPARAM lp){
AppMsgProcessor amp;
amp.ProcessMessage(wp, lp);
return(0);
}
I explained the "reports back" process as matching the message routine
of the other threads... ie using the MessageMgr class' function
SendMsgToDlg which I outlined above. So:
void AppMsgProcessor::ProcessMessage(WPARAM wp, LPARAM lp){
... // Do something to convert lp to CString and process
MessageMgr msg;
msg.SendMsgToDlg(lpConvertedtoCString, LISTCTRL_1);
}
to:
void MessageMgr::SendMsgToDlg(const char* strMsg, int msgType){
CString * s = new CString(strMsg);
pDlg->PostMessage( UWM_ADDSTRING, msgType, LPARAM(s));
}
< If you are doing a call, and the
call is from a message handler, the message pump is blocked until the control returns from
the call and therefore the handler returns to DispatchMessage.
Yes, this is what I thought as well... which is why I brought up this
section of code. However, like I said, as soon as that PostMessage is
called the original call should return and it should go back to
processing the messages and posting them to the list controls. Why it
is freezing interminably is what I'm really confused about. Could this
be enough to cause a deadlock with multiple cores/processors?
Marcus