Timer fireing off twice in a row when it should not
I am doing a little work with a timer in my program to control a thread. The only code I have in the timer is in the tick event which has the line
Console.WriteLine = "Test"
I set the timers interval to 10 seconds in the desgin view. When I start my timer I get two Tests in the console window really fast then 10 seconds go by and another two Test but, I only have one test in the tick event.
I set a break at the timer tick event and when the event is fire it ads a line to the console then refires it self yet there is not code that is doing this.
What am I doing wrong?
Re: Timer fireing off twice in a row when it should not
A timer's interval uses milliseconds, not seconds. For example, if you wanted 1 second, you would have to put in 1000. For 10 seconds, 10000.
Re: Timer fireing off twice in a row when it should not
yea i know it's miliseconds I have the timer set to 10,000
Re: Timer fireing off twice in a row when it should not
Move your code to the timers elapse event not the tick event.
Re: Timer fireing off twice in a row when it should not
Elaspe and tick are events from 2 different timers
System.Timers.Timer uses elapse
Windows.Forms.Timer uses tick
porsche can you post the code in the tick event?
Re: Timer fireing off twice in a row when it should not
Check to make sure you are not adding the handler twice to handle the event. Check the windows generated code section.
The most common cause of this is you have an "add handler" in the generated code and a "handles Timer1.Tick" after the function.