How to find out if a Timer is running?

.NetTimer

.Net Problem Overview


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 Solutions


Solution 1 - .Net

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

Solution 2 - .Net

if (timer1.Enabled)
{
   // Do Something
}

Solution 3 - .Net

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.

Solution 4 - .Net

Use the timer's Enabled property.

Solution 5 - .Net

You should check that timer is enabled

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionGeorge MauerView Question on Stackoverflow
Solution 1 - .NetRon SavageView Answer on Stackoverflow
Solution 2 - .NetInisheerView Answer on Stackoverflow
Solution 3 - .NetJoeView Answer on Stackoverflow
Solution 4 - .NetBob KingView Answer on Stackoverflow
Solution 5 - .NetJohnno NolanView Answer on Stackoverflow