Message Loops can be written with the following properties.
IsThreadModal – returns whether the application has gone modal (e.g., a modal message loop has been pushed). ComponentDispatcher can track this state because the class maintains a count of ‘PushModal’ and ‘PopModal’ calls from the message loop.
ThreadFilterMessage and ThreadPreprocessMessage events follow the standard rules for delegate invocations. Delegates are invoked in an unspecified order and all delegates are invoked even if the first one marks the message as handled.
ThreadIdle – indicates an appropriate and efficient time to do idle processing (there are no other pending messages for the thread). ThreadIdle will not be raised if the thread is modal.
ThreadFilterMessage – raised for all messages that the message pump processes.
ThreadPreprocessMessage – raised for all messages that were not handled during ThreadFilterMessage.