Click or drag to resize
DispatcherTimer Class
Provides a timer that is integrated into the Dispatcher queue, which is processed at a specified interval of time and at a specified priority. One scenario for this is to run code on the UI thread.
Inheritance Hierarchy
SystemObject
  Windows.UI.XamlDispatcherTimer

Namespace: Windows.UI.Xaml
Assembly: CSharpXamlForHtml5 (in CSharpXamlForHtml5.dll) Version: 1.0.0.0
Syntax
C#
public class DispatcherTimer

The DispatcherTimer type exposes the following members.

Constructors
  NameDescription
Public methodDispatcherTimer
Initializes a new instance of the DispatcherTimer class.
Top
Methods
  NameDescription
Public methodEquals(Object)
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Protected methodOnTick
Raises the Tick event.
Public methodStart
Starts the DispatcherTimer.
Public methodStop
Stops the DispatcherTimer.
Public methodToString
Returns a string that represents the current object.
(Inherited from Object.)
Top
Properties
  NameDescription
Public propertyInterval
Gets or sets the amount of time between timer ticks.
Public propertyIsEnabled
Gets a value that indicates whether the timer is running.
Top
Events
  NameDescription
Public eventTick
Occurs when the timer interval has elapsed.
Top
Examples
Here is how you can create and use a DispatcherTimer:
C#
DispatcherTimer _dispatcherTimer;
C#
//We create a new instance of DispatcherTimer:
_dispatcherTimer = new Dispatchertimer();
//we set the time between each tick of the DispatcherTimer to 100 milliseconds:
timer.Interval = new TimeSpan(0, 0, 0, 0, 100);
_dispatcherTimer.Tick += DispatcherTimer_Tick;
_dispatcherTimer.Start();
C#
void DispatcherTimer_Tick(object sender, object e)
{
    //Some code to execute at each Tick of the DispatcherTimer.
}
When you want to stop the DispatcherTimer, you can use the following code:
C#
_dispatcherTimer.Stop();
See Also