title: System.Timers.Timer interval resetting causing restart
body: <p>I'm running into a problem with the System.Timers.Timer in a windows service. I basically set the timer up in a base polling service class with the following code:</p>
  
  <pre><code>_serviceTimer.Elapsed += OnElapsedTime;
  _serviceTimer.Interval = ServiceTimerInterval.TotalMilliseconds;
  _serviceTimer.AutoReset = false;
  _serviceTimer.Enabled = true;
  </code></pre>
  
  <p>When the OnElapsedTime fires, I want to disable the timer and set the interval to a different value based on a lookup. The problem is when I change the interval it actually restarts the timer. This strange behavior is mentioned in the msndn docs with: </p>
  
  <p>Note:
  If Enabled and AutoReset are both set to false, and the timer has previously been enabled, setting the Interval property causes the Elapsed event to be raised once, as if the Enabled property had been set to true. To set the interval without raising the event, you can temporarily set the AutoReset property to true.
  <a href="http://msdn.microsoft.com/en-us/library/system.timers.timer.interval.aspx" rel="nofollow">Timer.Interval</a></p>
  
  <p>In the onelapsed event I have this:</p>
  
  <pre><code>_serviceTimer.Enabled = false;
  double newIntervalSetting = newSetting;
  base._serviceTimer.AutoReset = true;
  base._serviceTimer.Interval = newIntervalSetting;
  base._serviceTimer.AutoReset = false;
  //reenable after processing
  </code></pre>
  
  <p>The problem is the interval change still begins the timer countdown and eventually fires off the event even though I set the autoreset to true prior to changing the interval. The enabled remains false at all times, but the event still fires. I'm not sure if I'm misinterpreting the msdn docs about the correct way to do this. Can anyone help me out?</p>