I have a main program that creates the threads in order: ThreadB then ThreadA (which is passed ThreadB's ID) using the CreateThread function.
Thread A sends a message to Thread B using PostThreadMessage. B gets the message using GetMessage.
The problem I am having is that PostThreadMessage blocks randomly the first time it is called and never returns, some times the program funs fine, other times I run the program and it blocks with 0 CPU usage at the first postthreadmessage. However if I add Sleep(10) to ThreadA before the first PostThreadMessage, I never seem to encouter this problem.
What am I missing about the timing of threads and messages?