System.Timers Namespace

System.Timers 命名空间提供 Timer 组件,它使您可以在指定的间隔是引发事件。 The System.Timers namespace provides the Timer component, which allows you to raise an event on a specified interval.

ElapsedEventArgs

Elapsed 事件提供数据。 Provides data for the Elapsed event.

Timer

在设定的间隔之后生成事件,带有生成重复事件的选项。 Generates an event after a set interval, with an option to generate recurring events.

TimersDescriptionAttribute

设置可视化设计器在引用事件、扩展程序或属性时可以显示的说明。 Sets the description that visual designers can display when referencing an event, extender, or property.

委托

ElapsedEventHandler

表示将用来处理 ElapsedTimer 事件的方法。 Represents the method that will handle the Elapsed event of a Timer.

注解

Timer组件是一种基于服务器的计时器,以便您可以指定的重复间隔Elapsed在应用程序中引发事件。The Timer component is a server-based timer, which allows you to specify a recurring interval at which the Elapsed event is raised in your application. 然后,可以处理此事件来提供常规处理。You can then handle this event to provide regular processing. 例如,假设您有必须保持的关键服务器运行每周 7 天、 每天 24 小时。For example, suppose you have a critical server that must be kept running 24 hours a day, 7 days a week. 可以创建使用服务Timer来定期检查服务器,并确保系统已启动并运行。You could create a service that uses a Timer to periodically check the server and ensure that the system is up and running. 如果系统未响应,则服务可能尝试以重新启动服务器,或通知管理员。If the system is not responding, the service could attempt to restart the server or notify an administrator.

基于服务器的Timer设计用于在多线程环境中的工作线程。The server-based Timer is designed for use with worker threads in a multithreaded environment. 服务器的计时器可以在线程之间移动来处理引发Elapsed事件,从而导致比 Windows 计时器中在时间上引发事件的更精确。Server timers can move among threads to handle the raised Elapsed event, resulting in more accuracy than Windows timers in raising the event on time.