This documentation is archived and is not being maintained.

DispatcherTimer.IsEnabled Property

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

Namespace:  System.Windows.Threading
Assembly:  WindowsBase (in WindowsBase.dll)
XMLNS for XAML: Not mapped to an xmlns.

public bool IsEnabled { get; set; }
<object IsEnabled="bool" .../>

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

Supported in: 4, 3.5, 3.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Show: