0

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. :)

user541686
  • 205,094
  • 128
  • 528
  • 886

1 Answers1

2

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.

See also an example of what can go wrong:

Community
  • 1
  • 1
Ben
  • 34,935
  • 6
  • 74
  • 113