Actually I have two questions:
- Is it safe to call
SendMessagefrom a worker thread? - Do
CWndmethods, likeMessageBox, call API functionSendMessagebehind the scene?
Per my understanding, when the worker thread calls SendMessage, it pushes the message into the message queue of the UI thread, and waits until this message is processed. In that case, it would be safe to do so.
I'm not quite sure about this. please correct me if I was wrong.
Thanks a lot.
------------------------ update ----------------------------------
As a conclusion:
- It's safe to call the windows API
::SendMessageand::PostMessageacross threads. - It's not safe to call
CWndmethods across threads. Some of the methods may be safe, but it's not guaranteed.
Great thanks to everyone.