title: System.ApplicationException: Error in the application in DeleteTimerNative
body: <p>In our code we have a timer which will check whether the server is connected or not. If it is not connected will try to reconnect the server.</p>
  
  <p>The code is as below </p>
  
  <pre><code>private void timer_Elapsed(object source, ElapsedEventArgs e)
  {
     timer.Stop();
     if (timer.Interval != serverTimeOut)
     {
       timer.Interval = serverTimeOut;
     }
  
     timer.Start();
     //below the code to check whether server connected or not
  
  }
  </code></pre>
  
  <p>We are getting the exception like</p>
  
  <pre><code>Class: System.Threading.TimerBase
  Function: DeleteTimerNative
  Exception: System.ApplicationException: Error in the application.
     at System.Threading.TimerBase.DeleteTimerNative(SafeHandle notifyObject)
     at System.Threading.TimerBase.Dispose()
     at System.Threading.Timer.Dispose()
     at System.Timers.Timer.set_Enabled(Boolean value)
     at System.Timers.Timer.Stop()
     at ServerConnection.timer_Elapsed(Object source, ElapsedEventArgs e)
  </code></pre>
  
  <p>In the elapsed event we are stopping the timer and changing the interval and again will start timer. Is this steps will cause any exception? </p>