Message Queues

[ snippet from code project ]

Let’s go deeper into the Win32 world. There are two fundamental Win32 API calls to access and/or modify a control, SendMessage andPostMessage. There is a big difference in the way the two execute. The major difference is that SendMessage blocks the caller till the message gets processed by the message pump whereas PostMessage returns immediately. The subtle but important difference is that messages sent usingSendMessage aren’t queued in the message queue whereas PostMessage messages are. SendMessage messages are directly “sent” to the message pump. The message pump retrieves and processes messages sent using SendMessage before looking into those in the message queue. Effectively, there are then two queues, one for SendMessage messages and one for PostMessage messages (which is what we call the message queue). The message pump processes all messages in the first queue before starting with the second. An interesting observation is that if code does aSendMessage from within the message pumping thread, the window procedure gets called directly, that is, it doesn’t go through the message pump

[ /end snip ]

(More)

Don't be shellfish...Share on FacebookShare on Google+Tweet about this on TwitterShare on LinkedInShare on TumblrEmail this to someone

Leave a Reply