Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
BRH 48
#DOTNET 34
#ASP.NET 29
jQuery 22
ASP.NET 20
.NET 20
WPF 9
jquery interview questions 9
jquery faq 8
ASP.NET4 8

Archive · View All
February 2011 10
September 2011 4
August 2011 4
July 2011 4
May 2011 4
April 2011 4
March 2011 4
October 2011 4
June 2011 4
January 2011 4

What is a dispatcher Object?

Jul 22 2011 4:56PM by Hima   

  • Every UIElement in WPF is derived from DispatcherObject which defines a property called Dispatcher that points to the UI thread.
  • A dispatcher is used to raise calls on another thread.
  • Dispatcher can also be called as a  class that handles thread affinity.

Thread Affinity

As mentioned  above Dispatcher thread holds all UI elements. This is called thread affinity. All Most all of the WPF elements have thread affinity. If we have a background thread working, and if at all we need to update the UI thread, then a dispatcher is definitely required for this. Thus from any other thread, if at all we want to access UI component, we need to do it using Dispatcher thread.

DispatcherObject class contains two methods .

1. CheckAccess() : This method provides access to current dispatcher that an object is tied to . This returns a Boolean value as true if the current thread has access to use the object and returns false if the current thread can not use the object.

2. VerifyAccess() : The purpose of this method is to Verify  if the thread has access to the object. If the thread does not have access to the object, an exception is thrown.

If we make a call to a DispatcherObject from a non-UI thread, it will throw an exception. So if we are working on a non-UI thread, we need to update DispatcherObjects by using dispatcher.

The below picture represents object hierarchy in WPF.  It gets inherited from Object class.

WPF-object-heirarchy

Dispatcher object  represents an object associated with a System.Threading.Dispatcher.

As conclusion, we can say that, it is actually an important message loop through which all elements are managed.

Tags: dispatcher object,WPF interview FAQ, thread affinity, WPF architecture, internals of WPF,


Hima
31 · 6% · 1776
2
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"What is a dispatcher Object?" rated 5 out of 5 by 2 readers
What is a dispatcher Object? , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]