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



Answer this question

How to trigger a window service to start every 10 secs

  • Eric Delaune

    Use a timer in your service.

  • 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 runtime

    Now 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


  • How to trigger a window service to start every 10 secs