SendMessageTimeout, Wm_COPYDATA, interlocking
HI,
I am trying to port a sofwtare on pocket pc.
Here is the architecture :
I have two different processes (client/server)that communicates via a
WM_COPYDATA.
In the direction of Server->Client, SendMessage is used
In the direction of CLient->Server, SendMessageTimeout with SMTO_BLOCK
(Prevents the calling thread from processing any other requests until
the function returns)
The problem is on pocket SendMessageTimeout only have a SMTO_NORMAL
parameter. It means the calling thread is not blocked.
Here is the situation :
My server sends to my client a WM_COPYDATA via a SendMessage.
My client receives the WM_COPYDATA and during the message processing
call a method called GetInfo that send WM_COPYDATA to get information
from server.
#ifdef _WIN32_WCE
#define SM_GEN_SMTO SMTO_NORMAL
#else // _WIN32_WCE
#define SM_GEN_SMTO SMTO_BLOCK
#endif // _WIN32_WCE
CSyncCLientApi::GetInfo(..)
{
ULong_t lResult = SendMessageTimeout( m_hServer, WM_COPYDATA, 0, (
LPARAM ) &CopyData, SM_GEN_SMTO, 1500,&rcMsg );
}
BOOL CMainFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct)
{
switch( l_pSyncMessage->nState )
{
case SYNC1:
GetInfo(..);
break;
case SYNC2:
GetInfo(..);
break;
}
return CFrameWnd::OnCopyData(pWnd, pCopyDataStruct);
}
When I try to debug I put a breakpoint in the SYNC1 case and when I
pass after the SendMessageTimeout, I RE-ENTER into the GetInfo function
because of the case SYNC2.
It means that my first GetInfo always receives bad data.
I am a bit lost ...