Manually Firing off Timer.ElapsedEvent

  • Thread starter Thread starter Weston Weems
  • Start date Start date
W

Weston Weems

Hello,

I've got timers launching every 3 minutes to run a
somewhat lengthy process etc... and that all works fine.

What I'd like is to have the timer fire immediately after
starting then at <X> intervals.

With System.Timers.Timer, is there a way I can manually
fire off the event. Or will I just have to manually create
a thread and fire the event the first time?

Seems like its pretty common behavior to want a timer to
fire once started then fire at x intervals.

Thanks in advance
Weston Weems
 
You may want to take a look at the System.Threading.Timer class
instead. This is a thread-safe representation of a timer and differs
from the Timers namespace in a couple of ways. First the constructor
allows you to specify when the first timer should fire (which you want
to fire right away) and then to specify an interval for how often it
should fire after the first one.
Secondly, instead of using events and event handlers, you are simply
able to specify a callback function.
Hope this helps
Rob Vretenar [imason inc.]
 
Back
Top