Reputation: 210633
Is it possible to somehow cleverly use PostMessage
, GetMessage
, etc. to queue LIFO messages (assuming both the sender and the receiving message loop cooperate), or would I need to roll my own solution?
In case you're wondering about the use case, it's icon loading. You always want to load the most recently requested icons first. :)
Upvotes: 0
Views: 264
Reputation: 35643
No, you need to roll your own - the windows message queue has a maximum size, and if it ever gets full all sorts of things go badly wrong, from COM, DDE to user interaction.
Instead of using the thread queue, you should use a deque (or similar) protected by a critical section.
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.
See also an example of what can go wrong:
Upvotes: 2