#28 – DispatcherObject

The DispatcherObject class represents an object associated with a Dispatcher.  A dispatcher handles a queue of requests to do work on a particular thread.  It has the ability to invoke methods on its associated thread.

DispatcherObject is a base class for objects that keep track of the Dispatcher associated with the thread that they were created on.

WPF controls inherit from DispatcherObject because they need their methods called from the thread on which they were created.

DispatcherObject has two methods that help with ensuring that a control’s methods are called from the proper thread.

  • CheckAccess – Check whether the current thread can call methods on the control
  • VerifyAccess – If no access, throw InvalidOperationException

If a control determines that the current thread doesn’t have access, it can use its Dispatcher property (also in DispatcherObject) to call a method on the correct thread.

Advertisements

About Sean
Software developer in the Twin Cities area, passionate about software development and sailing.

One Response to #28 – DispatcherObject

  1. johnyao123 says:

    It’s a great help that you use simple clear language to explains the mysterious jargon of WPF. Thank you Sean!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: