Timer causes crash?

munkee

Active member
Joined
Feb 20, 2007
Messages
43
Programming Experience
Beginner
So I've been using a timer to do a function every 10 minutes...

The way I originally had it setup was that the timer would count up to "600 seconds" in a text box. If the text box equals that value, then go on to the next step.

I've been running into some issues lately with some units going to the next step, and some not. Could this be a problem with how each system uses the Timer intervals differently?

I read this thread (http://www.vbdotnetforums.com/showthread.php?t=18936) and feel it would be a great solution to my problem, but am just curious as to whether or not improper use of the Timer could/would cause the software to crash.

Thanks,
Ron
 
Dont use timer events to look for equivalence to a certain value. Always apply a range bounded check


Suppose we have a timer ticking ever second and every second we check whether the time is exactly on the minute..

Now suppose the user loads a scratched CD into the CD-ROM (one thing that is great for bringing a computer to its knees) and your timer gets a slow-go..
It ticked at 12:03:59.789
Then it hits a slow go and actually 1.4 seconds passes before it fires again
The time is now 12:04:01.189

You missed your event..


Whereas if you had recorded the time of the last event, and subtracted it from the time it is now, and seen if the period was longer than 60 seconds, you would have always hit your event.

Never use equality, always use range bounded checks
 
Back
Top