How to find out if a Timer is running?

2019-02-21 06:46发布

If I have an instance of a System.Timers.Timer that has a long interval - say 1 minute, how can I find out if it is started without waiting for the Tick?

标签: .net timer
5条回答
Viruses.
2楼-- · 2019-02-21 07:20

You should check that timer is enabled

查看更多
Animai°情兽
3楼-- · 2019-02-21 07:31

Use the timer's Enabled property.

查看更多
做自己的国王
4楼-- · 2019-02-21 07:40

System.Timer.Timer.Enabled should work, when you call "Start" it sets Enabled to TRUE, "Stop" sets it to FALSE.

查看更多
可以哭但决不认输i
5楼-- · 2019-02-21 07:41
if (timer1.Enabled)
{
   // Do Something
}
查看更多
贼婆χ
6楼-- · 2019-02-21 07:41

If Timer.Enabled is true, your timer is running.

Calling Timer.Start sets Enabled to true.

Calling Timer.Stop sets Enabled to false.

If Timer.AutoReset is true, then Enabled will automatically be set to false the first time the timer expires.

查看更多
登录 后发表回答