简体   繁体   English

.Net等效于TTimer Delphi组件

[英].Net equivalent for the TTimer Delphi component

Exist a .net class equivalent to the TTimer delphi component? 是否存在一个与TTimer delphi组件等效的.net类?

TTimer is used to simplify calling the Windows API timer functions SetTimer and KillTimer, and to simplify processing the WM_TIMER messages. TTimer用于简化对Windows API计时器函数SetTimer和KillTimer的调用,并简化对WM_TIMER消息的处理。 Use one timer component for each timer in the application. 应用程序中的每个计时器都使用一个计时器组件。

The execution of the timer occurs through its OnTimer event. 计时器的执行通过其OnTimer事件发生。 TTimer has an Interval property that determines how often the timer's OnTimer event occurs. TTimer具有一个Interval属性,该属性确定计时器的OnTimer事件发生的频率。 Interval corresponds to the parameter for the Windows API SetTimer function. 时间间隔对应于Windows API SetTimer函数的参数。

Thanks in advance. 提前致谢。

Several! 一些! The closest to the Delphi TTimer is probably System.Windows.Forms.Timer , but there are also System.Timers.Timer and System.Threading.Timer for use in non-WinForms environments. 最接近Delphi TTimer的可能是System.Windows.Forms.Timer ,但是还有在非WinForms环境中使用的System.Timers.TimerSystem.Threading.Timer

Here's probably what you want: Timer Component (Windows Form) 这可能是您想要的: 计时器组件(Windows窗体)

And since there are more than only one Timer in .NET, here's a place where they compare them and explains the differences: Comparing the Timer Classes in the .NET Framework Class Library 而且由于.NET中不止一个Timer,因此在这里可以对它们进行比较并解释不同之处: 比较.NET Framework类库中的Timer类

Perhaps System.Diagnostics.Stopwatch will do what you want? 也许System.Diagnostics.Stopwatch会做您想要的?

Edit: Sorry, I didn't realize that Stopwatch doesn't provide events. 编辑:对不起,我没有意识到秒表不提供事件。 As itowlson mentioned, use System.Windows.Form.Timer or System.Threading.Timer. 如itowlson所述,请使用System.Windows.Form.Timer或System.Threading.Timer。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM