简体   繁体   English

如何将倒数计时器设定为每小时

[英]How to set a countdown timer to hourly

From my understanding, interval is based on miliseconds in c#. 据我了解,间隔是基于c#中的毫秒数。 However, I would wish to set my timer based on hourly. 但是,我希望基于小时设置计时器。

How do I do so? 我该怎么做? Do I change the interval under the timer properties to 3600000 ? 我是否将计时器属性下的间隔更改为3600000

If you are concerned about the readability of your code, you could use System.TimeSpan to clarify your intent: 如果您担心代码的可读性,可以使用System.TimeSpan来阐明您的意图:

timer.Interval = TimeSpan.FromHours(2).Milliseconds

This will set the interval of the timer to 2 hours. 这会将计时器的间隔设置为2小时。

yes

but you can use something like 但您可以使用类似

int hour = 1;
int setinterval = hour * 60 * 60 * 1000;
timerName.Interval = setinterval;

尝试这个 :

("YourCountdownTimer").Interval = 1 * 60 * 60 * 1000; 

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

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