title: Calling method at the start of windows service in c#
body: <p>Please look at this piece of code</p>
  
  <pre><code> public partial class TestService : ServiceBase
   {
       private static System.Timers.Timer aTimer;
  
       protected override void OnStart(string[] args)
       {
          aTimer = new Timer(10000 * 6 * 5); //  5 minutes interval
          aTimer.Elapsed += new ElapsedEventHandler(OnTimedEvent);
          aTimer.Enabled = true;
       }
  
       private void OnTimedEvent(object source, ElapsedEventArgs e)
       {
        ......
       }
   }
  </code></pre>
  
  <p>When I start this service at say 4:00 pm, the first time OnTimedEvent is called is at 4:05 pm, then 4:10 pm and so on. I would like the OnTimedEvent to be called at 4:00 pm as soon as I start the service. Is there anything I am missing here?</p>