title: Windows Service System.Timers.Timer not firing
body: <p>I have a Windows service written in C# which is meant to perform a task every few minutes.  I'm using a <code>System.Timers.Timer</code> for this but it doesn't ever appear to fire.  I've looked at <em>many</em> different posts here on SO and elsewhere and I'm not seeing what is wrong with my code.</p>
  
  <p>Here is my code, with non-timer related items removed for clarity...</p>
  
  <pre><code>namespace NovaNotificationService
  {
      public partial class NovaNotificationService : ServiceBase
      {
          private System.Timers.Timer IntervalTimer;
          public NovaNotificationService()
          {
              InitializeComponent();
              IntervalTimer = new System.Timers.Timer(60000);  // Default in case app.config is silent.
              IntervalTimer.Enabled = false;
              IntervalTimer.Elapsed += new ElapsedEventHandler(this.IntervalTimer_Elapsed);
          }
  
          protected override void OnStart(string[] args)
          {
              // Set up the timer...
              IntervalTimer.Enabled = false;
              IntervalTimer.Interval = Properties.Settings.Default.PollingFreqInSec * 1000;
              // Start the timer and wait for the next work to be released...
              IntervalTimer.Start();
          }
  
          protected override void OnStop()
          {
              IntervalTimer.Enabled = false;
          }
  
          private void IntervalTimer_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
          {   // Do the thing that needs doing every few minutes...
              DoWork();
          }
      }
  }
  </code></pre>
  
  <p>I'm really scratching my head over this one.  Can anybody spot what silly thing I'm getting wrong?</p>
  
  <p><strong>EDIT:</strong>
  By suggestion, I added <code>IntervalTimer.Enabled = true;</code> before <code>IntervalTimer.Start();</code> in the service OnStart method.  This doesn't resolve the issue.</p>
  
  <p>I've added file trace logging into the service to confirm some of the internals and I know for sure that the Timer.Enabled value is true by the time OnStart() is finished.</p>