Hi
I have encountered a strange problem: while using PostThreadMessage to communicate between threads of different processes, PostThreadMessage returns "The message can be used only with synchronous operations" (1159), I didn't find any documentation discussing this error in details, does anyone has a clue??? What am I doing wrong here? Why should PostThreadMessage return this kind of error
Following is the code used to post the message
int iSendCnt = 10
while(--iSendCnt > 0 && 0 == PostThreadMessage(dwDebuggerMsgThreadID, 1, 2300, 0)
Sleep(0)
NOTE that the thread referred to by 'dwDebuggerMsgThreadID' has a
message pump: while(0 != GetMessage(&msg, NULL, 0, 0)) { ........ }
Thanks
Nadav
William DePalo [MVP VC++] - 25 May 2004 01:12 GMT
> I have encountered a strange problem: while using
> PostThreadMessage to communicate between
> threads of different processes, PostThreadMessage
> returns "The message can be used only with synchronous
> operations" (1159), I didn't find any documentation discussing
> this error in details, does anyone has a clue???
Well, the error text reads "this message". You are posting message #1,
WM_CREATE. Why the heck is that? :-)
Seriously, Windows itself sends (it does not post) WM_CREATE messages in
response to CreateWindow[Ex](). Now I have never tried to post a WM_CREATE
so I can't be sure but my guess is that Windows is doing some sanity checks.
You should use WM_USER, WM_APP or a registered message for private
communication if windows are involved or some other IPC technique if they
are not.
Regards,
Will