On Sat Jun 29 02:26:59 2024 +0000, Jinoh Kang wrote:
SendMessage should be handles immediately, without going through the
message queue like that. Not if the window belongs to another thread. Pay special attention to the 4<sup>th</sup> paragraph of https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-sendm...:
If the specified window was created by the calling thread, the window
procedure is called immediately as a subroutine. **If the specified window was created by a different thread, the system switches to that thread and calls the appropriate window procedure.** Messages sent between threads are processed only when the receiving thread executes message retrieval code. [emphasis mine]
I wonder why it doesn't work.
Because sent messages (QS_SENDMESSAGE) take priority over hardware (QS_INPUT) messages. See server/queue.c, get_messages handler. Posted messages (QS_POSTMESSAGE) have the same problem. That is, we still need the WaitForSingleObject. My original proposal was to use SendMessage *in addition to* WaitForSingleObject, not replace it.
I see, so many tiny details.. So the only advantage SendMessage has over PostMessage is that we don't need the manual wait afterwards, right?
I pushed an update, is this good then?