"Explain "race condition" in the context of a single-threaded message pump."
I'm not talking about the message pump. I'm not talking about the function that processes the messages.
"common misconception that Windows passes messages asyncronously within an application"
Presumably you mean "within a single threaded application"? O_o
"But the short answer is no, the Windows [...] applications."
I'm really not getting these references to single threaded versus multiple thread contexts. I specifically mention race conditions and all windows in the system have the potential to be called from an outside thread or outside processes regardless of how the original client may have been written.
Stay with me for an example...
a.exe:
Code:
SendMessage(b.exe::hwnd, WM_WHATEVER, PARAM1, 0);
SendMessage(b.exe::hwnd, WM_WHATEVER, PARAM2, 0);
b.exe:
Code:
case WHATEVER:
//??? process state
ReplyMessage(0);
//??? process state
My understanding is that `SendMessage' posts a message to the queue if the call originates from a different thread. Now with a single threaded "b.exe" I can see how this wouldn't be a problem if and only if `DispatchMessage' waits until the message is processed. (If it returns before the message is processed another `GetMessage' plus `DispatchMessage' cycle may complete before the message is processed and after the second message is posted.)
Further, my understanding is that `SendMessage' basically just functions as a direct call to `WndProc' if originating from the same thread. With that in mind, I simply can't imagine what protections may have been in place to prevent race conditions within a multiple threaded application.
Now, I'm giving myself a leave because I hate the API and like pretend it doesn't exist. That doesn't really explain the various who call themselves "Windows® Programmers"--'R' and all--who, in my understanding, have basically guaranteed that their source will fail in any situation similar to the above. I want to know if this is some aspect of the message queuing facility I simply don't understand or if these individuals just didn't bother to deal with the potentially damaging lack of synchronization.
Soma