The call to
PostThreadMessage
is right thing, but only if your main thread runs Windows UI with the main cycle using
GetMessage-TranslateMessage-DispatchMessage
cycle as the function
WinMain
typically does.
As you're sending it to a main thread and still cannot get what you want, I assume your main thread does not do it. You cannot dispatch message to a arbitrary thread; you should write a special code for the thread accepting messages. One good way of doing this is making a blocking message queue. A receiving thread, being blocked, will be put to a wait state by OS and never scheduled back to execution until awaken be a next message or terminated.
Unfortunately, I only have C# code for such mechanism, not C++. But you can look it it, because it's clear enough to get the idea:
http://www.codeproject.com/Tips/149540/Simple-Blocking-Queue-for-Thread-Communication-and[
^].
Instead of
EventWaitHandle
you will need to use Windows Event object, see
http://msdn.microsoft.com/en-us/library/ms682655%28v=vs.85%29.aspx[
^].
—SA