Software Development Network>> Visual C#>> How to trigger a window service to start every 10 secs
Hi all,
I would like to know how can I trigger a window service "MyService" to start every 10 secs. Thanks
Exactly, use a timer and call that method that you want to execute.
Declare a timer object
System.Timers.
in the windows service OnStart method,
t.Interval = 10000; //10 Seconds
t.Start();
t.Elapsed +=
Now just add the code to the event handler.
Hope it helps
I did the same but my timer doesnot seem to work properly, as its elapsed event is not being called at specified interval. Is there some issue in using timer in window service. Thanks
How to trigger a window service to start every 10 secs
Eric Delaune
redneon
Exactly, use a timer and call that method that you want to execute.
Declare a timer object
System.Timers.
Timer t = new System.Timers.Timer();in the windows service OnStart method,
t.Interval = 10000; //10 Seconds
t.Start();
t.Elapsed +=
new System.Timers.ElapsedEventHandler(t_Elapsed); // Adds an event handler on runtimeNow just add the code to the event handler.
Hope it helps
JeroGrav
I did the same but my timer doesnot seem to work properly, as its elapsed event is not being called at specified interval. Is there some issue in using timer in window service. Thanks