Thread communication using SendMessage

Rivari picture Rivari · Jan 16, 2009 · Viewed 10.5k times · Source

my question is : how can I use SendMessage() to implement thread communication between two threads, one with a window (GUI) and the other with no window?

The problem is that SendMessage() needs a handle (HWND)?

Another detail about my project : Two threads, one running managed code (the one with the user interface), and the other running native code (the one without window)

Thank you very much!

Answer

Bob picture Bob · Jan 16, 2009

I would suggest creating a hidden window. When using postthreadmessage, there is a chance that your message could get lost (ie: if a messagebox is running the message loop).

More info about that at:

http://blogs.msdn.com/oldnewthing/archive/2005/04/26/412116.aspx