System.Windows.Forms.Timer Class

Implements a timer that raises an event at user-defined intervals. This timer is optimized for use in Windows Forms applications and must be used in a window.

See Also: Timer Members

Syntax

[System.ComponentModel.ToolboxItemFilter("System.Windows.Forms", System.ComponentModel.ToolboxItemFilterType.Allow)]
[System.ComponentModel.DefaultEvent("Tick")]
[System.ComponentModel.DefaultProperty("Interval")]
public class Timer : System.ComponentModel.Component

Remarks

A System.Windows.Forms.Timer is used to raise an event at user-defined intervals. This Windows timer is designed for a single-threaded environment where UI threads are used to perform processing. It requires that the user code have a UI message pump available and always operate from the same thread, or marshal the call onto another thread.

When you use this timer, use the Timer.Tick event to perform a polling operation or to display a splash screen for a specified period of time. Whenever the Timer.Enabled property is set to true and the Timer.Interval property is greater than zero, the Timer.Tick event is raised at intervals based on the Timer.Interval property setting.

This class provides methods to set the interval, and to start and stop the timer.

Note:

The Windows Forms Timer component is single-threaded, and is limited to an accuracy of 55 milliseconds. If you require a multithreaded timer with greater accuracy, use the System.Timers.Timer class in the System.Timers namespace.

Requirements

Namespace: System.Windows.Forms
Assembly: System.Windows.Forms (in System.Windows.Forms.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0