DispatcherTimer.IsEnabled Property

 

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

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

public bool IsEnabled { get; set; }

Property Value

Type: System.Boolean

true if the timer is enabled; otherwise, false. The default is false.

IsEnabled must be set to true for the Tick event to be raised.

Calling Start sets IsEnabled to true.

Calling Stop sets IsEnabled to false.

The following example creates a DispatcherTimer. A new DispatcherTimer object named dispatcherTimer is created. The event handler dispatcherTimer_Tick is added to the Tick event. The Interval is set to 1 second using a TimeSpan object.

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

.NET Framework
Available since 3.0
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Return to top
Show: