470,626 Members | 2,085 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,626 developers. It's quick & easy.

Strange error returned by 'PostThreadMessage'...

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
Nov 17 '05 #1
1 1619
"Nadav" <an*******@discussions.microsoft.com> wrote in message
news:68**********************************@microsof t.com...
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
Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by a_bogdan_marinescu | last post: by
5 posts views Thread by Tony Wright | last post: by
6 posts views Thread by Rick | last post: by
6 posts views Thread by | last post: by
7 posts views Thread by p | last post: by
reply views Thread by EMW | last post: by
11 posts views Thread by Gregor Kovańć | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.