简体   繁体   English

倒计时器

[英]countdown timer

trying to do a countdown timer in C# on micrsoft visual studio minimum value of 10seconds, maximum of 2hours need a display when timer runs out how do i implement this? 尝试在micrsoft visual studio上的C#中执行一个倒数计时器,最小值为10秒,最大值为2小时,当计时器用尽时需要显示该如何实现? thanks 谢谢

Use System.Threading.Timer wherein you can specify how much time should pass until the timer fires, and what code to execute when the timer does fire. 使用System.Threading.Timer ,您可以在其中指定在计时器启动之前应经过的时间,以及在计时器启动时执行哪些代码。

You can also look at the System.Windows.Forms.Timer . 您也可以查看System.Windows.Forms.Timer

For a comparison of all the timer-like classes in .NET, check out Comparing the Timer Classes in the .NET Framework . 要比较.NET中所有类似计时器的类,请查看.NET Framework中的比较计时器类

Use timers from System.Timer or System.Threading .Timer depends upon your needs. 使用System.TimerSystem.Threading .Timer取决于您的需要。 and execute your code in each interval. 并在每个间隔执行您的代码。

have a look at 看一下

http://msdn.microsoft.com/en-us/library/system.timers.timer.aspx http://msdn.microsoft.com/zh-CN/library/system.timers.timer.aspx

and

http://msdn.microsoft.com/en-us/library/system.threading.timer.aspx http://msdn.microsoft.com/zh-CN/library/system.threading.timer.aspx

if its a simple winforms app like u mentioned its a countdown app consider Forms.Timer its easier to implement. 如果它是一个像您提到的简单winforms应用程序,则它是一个倒计时应用程序,请考虑Forms.Timer易于实现。 Just drag and drop the control from toolbox and perform countdown in Tick Event. 只需从工具箱中拖放控件,然后在“ Tick事件”中执行倒数计时即可。 have a look for it here: 在这里看看:

http://msdn.microsoft.com/en-us/library/system.windows.forms.timer.aspx http://msdn.microsoft.com/zh-CN/library/system.windows.forms.timer.aspx

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

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