Suppose we are using System.Windows.Forms.Timer in a .Net application, Is there any meaningful difference between using the Start() and Stop() methods on the timer,
Here's a simple code to test how Enabled, Start(), Stop() work with each other.
Make a test Windows form app, add two simple buttons and paste this code inside Form1() constructor:
int c = 0;
Timer tmr1 = new Timer()
{
Interval = 100,
Enabled= false
};
tmr1.Tick += delegate
{
c++;
};
// used to continously monitor the values of "c" and tmr1.Enabled
Timer tmr2 = new Timer()
{
Interval = 100,
Enabled = true
};
tmr2.Tick += delegate
{
this.Text = string.Format("c={0}, tmr1.Enabled={1}", c, tmr1.Enabled.ToString());
};
button1.Click += delegate
{
tmr1.Start();
};
button2.Click += delegate
{
tmr1.Stop();
};