Size of the Message loop
-
Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.
-
Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.
From
PostMessage
function documentation onMSDN
[^]: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.
HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows NT
CurrentVersion
Windows
USERPostMessageLimitThe minimum acceptable value is 4000.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.
vc++_fragrance wrote:
1)How to handle the scenario... so that my application should not crash.
Your message loop should take care of this by processing every message on the queue. Only if the loop does not handle the messages is this likely to happen.
vc++_fragrance wrote:
- How to find the size of the Message queue.
I'm not sure if this information is available, but you could check the MSDN documentation[^] for further information.
-
From
PostMessage
function documentation onMSDN
[^]: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.
HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows NT
CurrentVersion
Windows
USERPostMessageLimitThe minimum acceptable value is 4000.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
Trust Microsoft to put this detail in the one function that I did not look at just now. :mad:
You should subscribe, like I did, the 'immediately informed by Microsoft about' neewsletter. :-D BTW: Merry Christmas!!! :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
You should subscribe, like I did, the 'immediately informed by Microsoft about' neewsletter. :-D BTW: Merry Christmas!!! :)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles] -
From
PostMessage
function documentation onMSDN
[^]: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.
HKEY_LOCAL_MACHINE
SOFTWARE
Microsoft
Windows NT
CurrentVersion
Windows
USERPostMessageLimitThe minimum acceptable value is 4000.
:)
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
[My articles]Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem. :) Happy Holidays to everyone.
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
-
Hi, In windows programming all the messages will be placed in the message queue for processing. Let us assume I have a dll which continuously raises events. These events will be placed in the Message queue. Now my doubt is, if the message queue fills , the application will crash. 1)How to handle the scenario... so that my application should not crash. 2) How to find the size of the Message queue. Thanks inadvance.
Either SendMessage can be used, or if you're afraid of the sender being taken into a deadlock, consider SendMessageTimeout[^] But more importantly, why is it that your DLL needs to continuously raise events and clobber the message queue? May be if you could explain your scenario, someone here might be able to suggest a better alternative. I say it because if you increase the message queue size on one computer, your program will still not work on another computer whose message queue size is the default! This is not a pretty sight.
“Follow your bliss.” – Joseph Campbell
-
Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem. :) Happy Holidays to everyone.
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]
Chris Meech wrote:
Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem.
Good Lord, so you've worked with that sort of horrendous applications? (I'm into that club too and I ended up rewriting an app once) BTW, Merry Christmas to you!
“Follow your bliss.” – Joseph Campbell
-
Chris Meech wrote:
Changing the limit is one alternative. Another is to check the return value from PostMessage. If the queue is full and the message can not be posted, I believe PostMessage returns a boolean false to indicate failure. Just wanted to suggest another way of looking at the problem.
Good Lord, so you've worked with that sort of horrendous applications? (I'm into that club too and I ended up rewriting an app once) BTW, Merry Christmas to you!
“Follow your bliss.” – Joseph Campbell
I have worker thread classes that query a database and post registered messages to controls. The loop that posts always seems to run faster than the UI thread can process. So I use a lock to throttle the worker thread when this happens. It was a difficult bug to deal with. :)
Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra]