c - Will MessageBox() "eat" my user-defined message? -
i have ui thread , thread, want send user-defined message using postmessage() other trhead ui thread.
if ui thread displays message box, , send user-defined message, message loop of message box retrieve user-defined message ui thread message queue, , hence user-defined message lost?!
postmessage() not problem. messagebox() runs own message loop make message box modal, makes call dispatchmessage() , function makes sure correct window procedure gets called message posted/sent window.
you make mistake if calling postthreadmessage() instead. never safe if receiving thread displays dialogs or enters modal loops. raymond chen wrote couple of blog articles that:
thread messages eaten modal loops
why messages posted postthreadmessage disappear?
a possible corner-case posting message requires message loop process message instead of window procedure. shortcut keystroke.
Comments
Post a Comment