1.system.timers.timer
(1) Generate recurring events in the application.
(2)If the SynchronizingObject property isnull, the Elapsed event is raised on the ThreadPool thread. If the Elapsed event is processed longer than Interval, this event will be raised again on another ThreadPool thread. in this case, the event handler should be reentrant.
(3)Even if SynchronizingObject is notnull, Elapsed The event can occur after the Dispose or Stop method call, or after the Enabled property is set to false, because the signal that leads to the Elapsed event is always queued for execution thread pool threads. one way to resolve this race condition is to set a flag that notifies the event handler for the Elapsed event that the subsequent event is ignored.
(4)When the Elapsed event is handled by a visual Windows forms component (such as a button), accessing the component through the system thread pool can cause an exception or may not work. to avoid this situation, you can set SynchronizingObject as a Windows forms component that will cause the method that handles the Elapsed event to be called on the same thread that created it.
2.System. Thread.timer
(1) The callback method executed by the timer should be reentrant because it is called on the ThreadPool thread.
(2) When you create a timer, you can specify the amount of time to wait before the first execution of the method (the cutoff time) and the amount of time to wait after the execution period (time period).
(3) SynchronizingObject is not supported.
3.system.windows.form.timer
(1) implements a timer that raises events on a user-defined interval. This timer is best used in Windows Forms applications and must be used in Windows.
Use of the timer