Is it possible to give window message different priority ?
-
hi all, I wonder if it is possible to give window message different priority, or in other word, one message can interrupt the message queue and is processed before other messages although it arrives in the message queue later. if that's not possible, what's your solution to handle the situations when a window have to process a long message queue, could be > 10 or even 20 messages waiting to be processed.
-
hi all, I wonder if it is possible to give window message different priority, or in other word, one message can interrupt the message queue and is processed before other messages although it arrives in the message queue later. if that's not possible, what's your solution to handle the situations when a window have to process a long message queue, could be > 10 or even 20 messages waiting to be processed.
GameProfessor wrote:
I wonder if it is possible to give window message different priority, or in other word, one message can interrupt the message queue and is processed before other messages although it arrives in the message queue
Not unless you invent it yourself with a different message queue that you handle yourself. Windows messages can be considered to have three priority levels. Posted messages have the highest priority. This means that they have a higher priority than input messages which are the next priority level. WM_PAINT and WM_TIMER have the lowest priority, in fact they are "pseudo" messages that not even make it to the message queue. The messages are simulated by setting a flag instead and they are processed when the message queue is empty. This also means that even if a timer has expired multiple times before being handled, the message handler for the WM_TIMER message will only be called once.
GameProfessor wrote:
if that's not possible, what's your solution to handle the situations when a window have to process a long message queue, could be > 10 or even 20 messages waiting to be processed.
Depends on the situation, you have to elaborate more on the problem you're trying to solve. I suspect I would use a worker thread reading a queue with application specific contents and not use the windows message queue. The thread would wait for a semaphore that is released when a new object is placed in the queue and process the new object. But this could be a bad solution, it depends on what you're trying to do.
"It's supposed to be hard, otherwise anybody could do it!" - selfquote
"High speed never compensates for wrong direction!" - unknown