well this time my question is not summarized in form of code. but i am asking it in different way.
I am working on mfc application and there is a condition in which i am posting window messages by using
PostMessageit is executing in a loop
Now after some time if i press close button at upper left corner that is not accepting it as the reason is message loop is processing other window messages which are generated in loop. I know its straight question..is there is way that i can do
that the priority of the close window (WM_CLOSE)
will be high than the other window messages.
Note: i cannot skip from posting the messages you can assume that is in loop of 30000.
any suggestion or link will be beneficial..
thanks in advance
Extended after your response Hi all first of all thanks everyone for answering. Yes there can be redesigned possible let me first tell you i do have a video recording of say 1 day. i am extracting frames on the basis of events.Suppose it is giving one frame at each second so data is extremely large. In this case what i am doing. i am extracting frame and do postmessage to display in listcontrol. Reason Why i am doing postmessage because i do not need to block the dialog(modelless) and it happening in thread data is coming continuously. Requirment: if there is any solution that i can avoid message loop will beneficial.
Edited 7-Jan-13 23:21pm
Have a look at PostQuitMessage
] try this to comeout of the message loop.
It also says
Quote:There is a limit of 10,000 posted messages per message queue. This limit should be sufficiently large. If your application exceeds the limit, it should be redesigned to avoid consuming so many system resources. To adjust this limit, modify the following registry key.
The answer to your question is basically: No, there is no way of giving a message a higher priority than others. For the Windows designers it was more important to implement the message queue as efficiently as possible and they voluntarily abstained from "luxuries" like prioritized message handling.
There is one exception to the rule: WM_PAINT message are treated specially and are always processed last, i.e. when no other message remain in the queue; several WM_PAINTs to the same window are combined to reduce the painting overhead even further.
As SA already pointed out: Blowing some 30000 messages onto your message queue is probably not the wisest thing to do. So re-think your application and find a way to limit the number of message posts, e.g. by using a simple intermediate class that counts the number of outstanding posts and blocks the poster at a reasonable threshold -- for as long as the consuming side has processed some of those messages.
And as SA also said: If you tell us what you are actually trying to accomplish we could perhaps help with some more concrete hints.
One of the things you can do is in your message processing loop, do a PeekMessage() periodically and look for a termination message. This will have the effect of a priority boost to the message. Don't do this frequently since this is a request to look through the entire message list until the desired message is found (ie. the entire list if it is not there).
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)