Timer

  • Thread starter Thread starter Darrin J Olson
  • Start date Start date
D

Darrin J Olson

I'm having some trouble with the System.Timer class. I created a console app
with an event that I fire on a 5 minute interval from the timer. This works
fine, for exactly 2 hours. After the timer fires the event 24 times, it
doesn't fire again.

I've tried using the System.Timer, the Threading.Timer and the Windows Forms
Timer (I instantiated a form that I did not show, just to use the timer). I
get the exact same results from each of them.

I've also tried stopping and restarting the timer every 30 minutes. Either
way, the event will fire for 2 hours, and will not fire again. Does anyone
know what might cause this?

Thanks!

-Darrin
 
The application currently doesn't run any methods other than the one that I
call from the Timer event. Is there anything wrong with just using
Thread.Sleep() in a loop?

I would like to know what the deal is with my Timer, though..?.?.

Thanks!

-Darrin
 
i don't know why you are seeing this behavior with the system.timer object.

if your app does nothing other than what occurs when the timer 'wakes up',
then sure you could use a thread.sleep call. you could also try a threading
timer...

Private _qThreadTimer As Threading.Timer

Private _qThreadCallback As Threading.TimerCallback

_qThreadCallback = New Threading.TimerCallback(AddressOf QueueCallback)

_qThreadTimer = New Threading.Timer(_qThreadCallback, Nothing, 5000, 5000)

Private Sub QueueCallback(ByVal state As Object)

End Sub
 
I've tried the Threading timer as you had listed below, and got the exact
same problem. 2 hours and it quits...

Even if the method does absolutely nothing, it ends after 2
hours...(envision programmer with wrinkled brow shaking his head back forth)
:-)

-Darrin
 
I have had more problems with system timers than I can count. I absolutly
refuse to use them any more. I hate how unreliable and unpredictable they
are. My advice is dont use system timers.

I might suggest spawing a seperate thread & using the kernal level sleep
event. Its much more reliable and more resource friendly.

g.
 
Can you show me some code. I've a timer running for about 2 months now in an
aspnet web application with no problems firing on the hour every hour
without fail. I suspect yours is not an aspnet page but I'm still curious as
to what is going on.
 
Back
Top