Actually I have two questions:
- Is it safe to call
SendMessage
from a worker thread? - Do
CWnd
methods, likeMessageBox
, call API functionSendMessage
behind 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
::SendMessage
and::PostMessage
across threads. - It's not safe to call
CWnd
methods across threads. Some of the methods may be safe, but it's not guaranteed.
Great thanks to everyone.