System.Timers.Timer.Stop Method

Stops raising the Timer.Elapsed event by setting Timer.Enabled to false.


public void Stop ()


You can also stop timing by setting Timer.Enabled to false.


The signal to raise the Timer.Elapsed event is always queued for execution on a System.Threading.ThreadPool thread, so the event-handling method might run on one thread at the same time that a call to the Timer.Stop method runs on another thread. This might result in the Timer.Elapsed event being raised after the Timer.Stop method is called. The code example in the next section shows one way to work around this race condition.


Namespace: System.Timers
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0,,