|
-
Oct 20th, 2006, 03:07 PM
#1
Thread Starter
Addicted Member
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?
-
Oct 20th, 2006, 03:18 PM
#2
Frenzied Member
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.
-
Oct 20th, 2006, 03:20 PM
#3
Thread Starter
Addicted Member
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
-
Oct 20th, 2006, 03:54 PM
#4
Fanatic Member
Re: Timer fireing off twice in a row when it should not
Move your code to the timers elapse event not the tick event.
-
Oct 20th, 2006, 04:01 PM
#5
Frenzied Member
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?
-
Oct 20th, 2006, 04:10 PM
#6
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|