Occurs when the interval elapses.
Assembly: System (in System.dll)
If Interval is set after the Timer has started, the count is reset. For example, if you set the interval to 5 seconds and then set Enabled to true, the count starts at the time Enabled is set. If you reset the interval to 10 seconds when count is 3 seconds, the event is raised for the first time 13 seconds after Enabled was set to true.
If the SynchronizingObject property is a null reference (Nothing in Visual Basic), the event is raised on a ThreadPool thread. If the processing of the event lasts longer than Interval, the event might be raised again on another ThreadPool thread. In this situation, the event handler should be reentrant.
The event-handling method might run on one thread at the same time that another thread calls the Stop method or sets the Enabled property to false. This might result in the event being raised after the timer is stopped. The example code for the Stop method shows one way to avoid this race condition.
Even if SynchronizingObject is not a null reference (Nothing in Visual Basic), events can occur after the Dispose or Stop method has been called or after the Enabled property has been set to false, because the signal to raise the event is always queued for execution on a thread pool thread. One way to resolve this race condition is to set a flag that tells the event handler for the event to ignore subsequent events.
The Timer component catches and suppresses all exceptions thrown by event handlers for the event. This behavior is subject to change in future releases of the .NET Framework.
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.