hmaturana
April 11th, 2004, 09:23 PM
CSimple is a class derivated from CWinThread
two threads are started in the process
pThread1 = AfxBeginThread(RUNTIME_CLASS(CSimple));
pThread2 = AfxBeginThread(RUNTIME_CLASS(CSimple));
Then a PostThreadMessage is sent to OnMessageServer
the value pMsg->m_iMessage inside OnMessageServer is 22
in the second PostThreadMessage the value of pMsg->iMessage
is 0.
long CSimple::OnMessageServer(UINT wParam, LPARAM lparam)
{
CMsg* pMsg = (CMsg*) lparam;
int iMessage = pMsg->m_iMessage;
TRACE("MessageReceived");
return 0;
}
{
CMsg* pMsg = new CMsg;;
pMsg->m_iMessage = 22;
pThread1->PostThreadMessage(WM_MESSAGE_SERVER, 0, (LPARAM)pMsg);
pMsg->m_iMessage = 11;
pThread2->PostThreadMessage(WM_MESSAGE_SERVER, 0, (LPARAM)pMsg);
delete(pMsg);
}
I do not know what the problem could be so any help will be apreciated.
Thank you
two threads are started in the process
pThread1 = AfxBeginThread(RUNTIME_CLASS(CSimple));
pThread2 = AfxBeginThread(RUNTIME_CLASS(CSimple));
Then a PostThreadMessage is sent to OnMessageServer
the value pMsg->m_iMessage inside OnMessageServer is 22
in the second PostThreadMessage the value of pMsg->iMessage
is 0.
long CSimple::OnMessageServer(UINT wParam, LPARAM lparam)
{
CMsg* pMsg = (CMsg*) lparam;
int iMessage = pMsg->m_iMessage;
TRACE("MessageReceived");
return 0;
}
{
CMsg* pMsg = new CMsg;;
pMsg->m_iMessage = 22;
pThread1->PostThreadMessage(WM_MESSAGE_SERVER, 0, (LPARAM)pMsg);
pMsg->m_iMessage = 11;
pThread2->PostThreadMessage(WM_MESSAGE_SERVER, 0, (LPARAM)pMsg);
delete(pMsg);
}
I do not know what the problem could be so any help will be apreciated.
Thank you