开发者

Sending message to different thread

开发者 https://www.devze.com 2022-12-12 03:27 出处:网络
Is there any API t开发者_开发技巧o send message to a thread? Basically I have only threadId available and I want to send a custom message to that thread.PostThreadMessage. Not very reliable though.

Is there any API t开发者_开发技巧o send message to a thread? Basically I have only threadId available and I want to send a custom message to that thread.


PostThreadMessage. Not very reliable though.

See The Old New Thing blog here and here for details on why. Basically modal message loops make a mess of the whole idea. Since a message posted to a thread has no window handle, calling DispatchMessage will throw the message away. Any modal loop you run - directly or indirectly - will call DispatchMessage, so a good proportion of the time this strategy will fail and your message will disappear into the ether.


you can use QueueUserAPC if the target thread is alertable

0

精彩评论

暂无评论...
验证码 换一张
取 消