語言

DispatcherTimer.IsEnabled 屬性

定義

取得或設定一個值,指示計時器是否正在運行。

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

屬性值

true如果計時器已啟用;否則,。 false 預設值為 false。

範例

以下範例會產生一個 DispatcherTimer。 會建立一個新的 DispatcherTimer 物件名稱 dispatcherTimer 。 事件處理 dispatcherTimer_Tick 程式會被加入事件 Tick 中。 在物件上Interval,該TimeSpan時間設定為 1 秒。

//  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()

備註

IsEnabled必須設定為 才能trueTick觸發事件。

呼叫 Start 將 設定 IsEnabled 為 true。

呼叫 Stop 將 設定 IsEnabled 為 false。

適用於