Manually Firing off Timer.ElapsedEvent

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
 
R

Rob Vretenar

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.]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top