SendMessage vs PostMessage
There’s another similar API which works exactly like SendMessage and that is
PostMessage API. Both require same parameters but there’s a slight difference.
When a message is sent to a window with SendMessage, the window procedure is
called and the calling program (or thread) waits for the message to be processed
and replied back, and until then the calling program does not resume its processing.
One thing is wrong with this approach however, that is if the program that is
busy carrying out long instructions or a program that has been hung and hence
no time to respond to the message will in turn hang your program too because
your program will be waiting for a reply that may never arrive. The solution
to this is to use PostMessage instead of SendMessage. PostMessage on the otherhand
returns to the calling program immediately without waiting for the thread to
process the message, hence saving your program from hanging. Which of them you
have to use depends on your requirement.