Posting too many messages
-
I'm sending (
PostMessage
) from a worker-thread to the main thread a custom message to do some refresh. What happens is that it looks that a big amount of messages are in some cases accumulated into the list of message. I don't want to reduce the rate of messages sent. Is there a simple way when posting [worker-thread] a new message to remove older (obsolete) message (of course the same message type) and leave there only the new one? Or it is possible to tell to the main thread to avoid to process a message if there is in the list the some copy less old than the current one?
Russell
-
I'm sending (
PostMessage
) from a worker-thread to the main thread a custom message to do some refresh. What happens is that it looks that a big amount of messages are in some cases accumulated into the list of message. I don't want to reduce the rate of messages sent. Is there a simple way when posting [worker-thread] a new message to remove older (obsolete) message (of course the same message type) and leave there only the new one? Or it is possible to tell to the main thread to avoid to process a message if there is in the list the some copy less old than the current one?
Russell
You can use SendMessageCallback[^] instead of
PostMessage
. This API return immediately just likePostMessage
. When the message handler is finished with processing the message the callback function passed in as parameter toSendMessageCallback
is called. This way you can keep track of whether a specific message handler has finished processing the message.«_Superman_» I love work. It gives me something to do between weekends.