แก้ไข

แชร์ผ่าน


DispatcherTimer.IsEnabled Property

Definition

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

public:
 property bool IsEnabled { bool get(); void set(bool value); };
public bool IsEnabled { get; set; }
member this.IsEnabled : bool with get, set
Public Property IsEnabled As Boolean

Property Value

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

Examples

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 = TimeSpan.FromSeconds(1);
dispatcherTimer.Start();
'  DispatcherTimer setup
dispatcherTimer = New Threading.DispatcherTimer()
AddHandler dispatcherTimer.Tick, AddressOf dispatcherTimer_Tick
dispatcherTimer.Interval = New TimeSpan(0,0,1)
dispatcherTimer.Start()

Remarks

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.

Applies to