Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happens if I call Start() two times on class System.Windows.Forms.Timer?

Tags:

c#

.net

vb.net

Imagine that I have a System.Windows.Forms.Timer with 1000 ms interval.

If I call Timer.Start() method and after 500 ms I call again Timer.Start() what happens? The second Start call will reset the interval or not? Are there any side effects?

like image 904
Drake Avatar asked Dec 28 '10 13:12

Drake


2 Answers

The timer is already started, so a second call will not affect it.

Regardless, this is easy to test.

like image 145
Oded Avatar answered Oct 27 '22 18:10

Oded


Start() just sets the Enabled property to true. If the Enabled property is already set to true it just sets Enabled to true again and keeps going.

Likewise, Stop() sets Enabled to false.

like image 39
Larry Hipp Avatar answered Oct 27 '22 19:10

Larry Hipp