DispatcherTimer Class
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
A timer that is integrated into the Dispatcher queue, which is processed at a specified interval of time and at a specified priority.
Inheritance Hierarchy
System..::.Object
System.Windows.Threading..::.DispatcherTimer
Namespace: System.Windows.Threading
Assembly: System.Windows (in System.Windows.dll)
Syntax
Public Class DispatcherTimer
public class DispatcherTimer
The DispatcherTimer type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
![]() |
DispatcherTimer | Initializes a new instance of the DispatcherTimer class. |
Top
Properties
| Name | Description | |
|---|---|---|
![]() |
Interval | Gets or sets the amount of time between timer ticks. |
![]() |
IsEnabled | Gets a value that indicates whether the timer is running. |
Top
Methods
| Name | Description | |
|---|---|---|
![]() |
Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() |
Finalize | Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.) |
![]() |
GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() |
GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() |
Start | Starts the DispatcherTimer. |
![]() |
Stop | Stops the DispatcherTimer. |
![]() |
ToString | Returns a string that represents the current object. (Inherited from Object.) |
Top
Events
| Name | Description | |
|---|---|---|
![]() |
Tick | Occurs when the timer interval has elapsed. |
Top
Remarks
The DispatcherTimer is reevaluated at the top of every DispatcherTimer 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 DispatcherTimer queue like other operations. When the DispatcherTimer operation executes is dependent on the other jobs in the queue and their priorities.
If a System.Threading..::.Timer is used, it is worth noting that the Timer runs on a different thread then the user interface (UI) thread. In order to access objects on the UI thread, it is necessary to post the operation onto the UI thread using Dispatcher..::.BeginInvoke. This is unnecessary when using a DispatcherTimer.
A DispatcherTimer will keep an object alive whenever the object's methods are bound to the timer.
Version Information
Windows Phone OS
Supported in: 8.1, 8.0, 7.1, 7.0
Platforms
Windows Phone
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
.gif)
.gif)
.gif)
.gif)