Lishi
Lishi

Reputation: 402

How robust are windows messages?

If i queue a message with PostMessage (and it return true) can i be certain that eventually the window will process the message unless some catastrophic event happen?(something which will crash the program anyway)

Upvotes: 6

Views: 286

Answers (2)

David Heffernan
David Heffernan

Reputation: 612954

You can be certain that the message will be in the queue if the call to PostMessage() succeeds.

PostMessage() will fail if the receiving queue is full. MSDN says:

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.

You can't be certain that posted messages will ever be processed because it's up to the other app to decide whether or not to pump its message queue.

This is being a little pedantic because in reality an app that doesn't ever pump its queues never gets run by anyone through a process of natural selection!

Upvotes: 4

sharptooth
sharptooth

Reputation: 170499

Once posted messages don't disappear from the queue.

One of our products is a Windows service that uses Windows messages to communicate between threads and it relies on them heavily. So far the only problem we've seen is that if you post them too fast the queue just fills and doesn't accept more messages until someone starts draining the queue.

Upvotes: 6

Related Questions