Export (0) Print
Expand All

Dispatcher.Invoke Method

Executes the specified delegate synchronously on the thread the Dispatcher is associated with.

Name Description
Dispatcher.Invoke (DispatcherPriority, Delegate) Executes the specified delegate synchronously at the specified priority on the thread on which the Dispatcher is associated with.
Dispatcher.Invoke (DispatcherPriority, Delegate, Object) Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
Dispatcher.Invoke (DispatcherPriority, TimeSpan, Delegate) Executes the specified delegate synchronously at the specified priority and with the specified time-out value on the thread the Dispatcher was created.
Dispatcher.Invoke (DispatcherPriority, Delegate, Object, Object[]) Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.
Dispatcher.Invoke (DispatcherPriority, TimeSpan, Delegate, Object) Executes the specified delegate at the specified priority with the specified argument synchronously on the thread the Dispatcher is associated with.
Dispatcher.Invoke (DispatcherPriority, TimeSpan, Delegate, Object, Object[]) Executes the specified delegate at the specified priority with the specified arguments synchronously on the thread the Dispatcher is associated with.

In WPF, only the thread which created a DispatcherObject may access that object. For example, a background thread which is spun off from the main UI thread cannot update the contents of a Button which was created on the UI thread. In order for the background thread to access the Content property of the Button, the background thread must delegate the work to the Dispatcher associated with the UI thread. This is accomplished by using either Invoke or BeginInvoke. Invoke is synchronous and BeginInvoke is asynchronous. The operation is added to the event queue of the Dispatcher at the specified DispatcherPriority.

Invoke is a synchronous operation; therefore, control will not return to the calling object until after the callback returns.

Community Additions

ADD
Show:
© 2014 Microsoft