DispatcherTimer Class


The .NET API Reference documentation has a new home. Visit the .NET API Browser on docs.microsoft.com to see the new experience.

A timer that is integrated into the Dispatcher queue which is processed at a specified interval of time and at a specified priority.

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


public class DispatcherTimer


Initializes a new instance of the DispatcherTimer class.


Initializes a new instance of the DispatcherTimer class which processes timer events at the specified priority.

System_CAPS_pubmethodDispatcherTimer(DispatcherPriority, Dispatcher)

Initializes a new instance of the DispatcherTimer class which runs on the specified Dispatcher at the specified priority.

System_CAPS_pubmethodDispatcherTimer(TimeSpan, DispatcherPriority, EventHandler, Dispatcher)

Initializes a new instance of the DispatcherTimer class which uses the specified time interval, priority, event handler, and Dispatcher.


Gets the Dispatcher associated with this DispatcherTimer.


Gets or sets the period of time between timer ticks.


Gets or sets a value that indicates whether the timer is running.


Gets or sets a user-defined data object.


Determines whether the specified object is equal to the current object.(Inherited from Object.)


Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)


Serves as the default hash function. (Inherited from Object.)


Gets the Type of the current instance.(Inherited from Object.)


Creates a shallow copy of the current Object.(Inherited from Object.)


Starts the DispatcherTimer.


Stops the DispatcherTimer.


Returns a string that represents the current object.(Inherited from Object.)


Occurs when the timer interval has elapsed.

The DispatcherTimer is reevaluated at the top of every Dispatcher loop.

Timers are not guaranteed to execute exactly when the time interval occurs, but they are guaranteed to not execute before the time interval occurs. This is because DispatcherTimer operations are placed on the Dispatcher queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.

If a System.Timers.Timer is used in a WPF application, it is worth noting that the System.Timers.Timer runs on a different thread then the user interface (UI) thread. In order to access objects on the user interface (UI) thread, it is necessary to post the operation onto the Dispatcher of the user interface (UI) thread using Invoke or BeginInvoke. Reasons for using a DispatcherTimer opposed to a System.Timers.Timer are that the DispatcherTimer runs on the same thread as the Dispatcher and a DispatcherPriority can be set on the DispatcherTimer.

A DispatcherTimer will keep an object alive whenever the object's methods are bound to the timer.

The following example creates a DispatcherTimer that updates the contents of a Label and calls the InvalidateRequerySuggested method on the CommandManager.

A DispatcherTimer object named dispatcherTimer is created. The event handler dispatcherTimer_Tick is added to the Tick event of dispatcherTimer. The Interval is set to 1 second using a TimeSpan object, and the timer is started.

//  DispatcherTimer setup
dispatcherTimer = new System.Windows.Threading.DispatcherTimer();
dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick);
dispatcherTimer.Interval = new TimeSpan(0,0,1);

The Tick event handler updates a Label that displays the current second, and it calls InvalidateRequerySuggested on the CommandManager.

//  System.Windows.Threading.DispatcherTimer.Tick handler
//  Updates the current seconds display and calls
//  InvalidateRequerySuggested on the CommandManager to force 
//  the Command to raise the CanExecuteChanged event.
private void dispatcherTimer_Tick(object sender, EventArgs e)
    // Updating the Label which displays the current second
    lblSeconds.Content = DateTime.Now.Second;

    // Forcing the CommandManager to raise the RequerySuggested event

.NET Framework
Available since 3.0
Available since 2.0
Windows Phone Silverlight
Available since 7.0

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

Return to top