WPF Thread Affinity
Dispatcherthat returns the
Dispatcherobject associated with the WPF element.
The Dispatcher Class
Dispatcherclass is used to perform work on his attached thread. It has a queue of work items and it is in charge of executing the work items on the dispatcher thread.
Dispatcherproperty to dispatch the operation to the correct thread. This is done using the BeginInvoke method that accepts a method to be invoked.
Where is the Dispatcher of the Thread Saved?
Of course, this list is synchronized using a
private global staticobject (this is a common best practice when locking object).
Threadproperty with the current thread, until they find the correct
dispatcherobject for this thread.
Dispatcherin the list.
|Inactive||Work items are queued but not processed.|
|SystemIdle||Work items are only dispatched to the UI thread when the system is idle. This is the lowest priority of items that are actually processed.|
|ApplicationIdle||Work items are only dispatched to the UI thread when the application itself is idle.|
|ContextIdle||Work items are only dispatched to the UI thread after higher-priority work items are processed.|
|Background||Work items are dispatched after all layout, rendering, and input items are processed.|
|Input||Work items are dispatched to the UI thread at the same priority as user input.|
|Loaded||Work items are dispatched to the UI thread after all layout and rendering are complete.|
|Render||Work items are dispatched to the UI thread at the same priority as the rendering engine.|
|DataBind||Work items are dispatched to the UI thread at the same priority as data binding.|
|Normal||Work items are dispatched to the UI thread with normal priority. This is the priority at which most application work items should be dispatched.|
|Send||Work items are dispatched to the UI thread with the highest priority.|