Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
ComponentDispatcher Class

ComponentDispatcher Class

Enables shared control of the message pump between Win32 and WPF in interoperation scenarios.


Namespace:  System.Windows.Interop
Assembly:  WindowsBase (in WindowsBase.dll)

public static class ComponentDispatcher

The ComponentDispatcher type exposes the following members.

Public propertyStatic memberCurrentKeyboardMessageGets the last message that was raised.
Public propertyStatic memberIsThreadModalGets a value that indicates whether the thread is modal.

Public methodStatic memberPopModalCalled to indicate that a modal thread is no longer modal.
Public methodStatic memberPushModalCalled to indicate that the thread is modal.
Public methodStatic memberRaiseIdleCalled to indicate that a thread is idle.
Public methodStatic memberRaiseThreadMessageIndicates that a new message is available for possible handling.

Public eventStatic memberEnterThreadModalOccurs when a thread becomes modal.
Public eventStatic memberLeaveThreadModalOccurs when a modal thread becomes nonmodal.
Public eventStatic memberThreadFilterMessageOccurs when the message pump receives a keyboard message.
Public eventStatic memberThreadIdleOccurs when the thread is idle.
Public eventStatic memberThreadPreprocessMessageOccurs when the message pump receives a keyboard message.

Although the class itself is static, all members of ComponentDispatcher are specific to a particular thread. For example, if you examine the value of IsThreadModal on two different threads, you might get different values.

The methods are static but they are backed by per-thread data structures.  The static methods allow singleton access but the ComponentDispatcher is sorting out the appropriate per-thread operations.

The owner of the message pump is defined by the code that calls the Win32 function GetMessage. The owner calls RaiseThreadMessage for every keyboard message. This method raises the ThreadFilterMessage event with the messages contained in the event data. If that event is not handled, the owner raises the ThreadPreprocessMessage event with the messages contained in the event argument.


Only keyboard messages are supported.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
© 2015 Microsoft