获得一个在C#中的系统时钟变化蜱 [英] Getting a system-clock-change-tick in C#

查看:150
本文介绍了获得一个在C#中的系统时钟变化蜱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

时的执行委托的方式事件在C#中的时候秒,分钟,小时,。 ..更改系统时钟,而不使用,检查每毫秒如果属性已经改变,执行与最大毫秒的延迟事件的计时器。

Is their a way to execute a delegate or event in C# when the seconds, minutes, hours,... change in the system-clock, without using a timer that checks every millisecond if the property has changed and executes the event with a delay of maximum a millisecond.

我因此,要避免的查询的和火在特定时间的事件。

I thus want to avoid polling and fire an event at a certain time.

推荐答案

如果你的问题是我如何执行代表每整秒/分钟/小时?

有关分钟和小时的时间间隔,你可以这样做在回答这个问题的SO所示:

For minute and hour intervals, you could do something like shown in my answer in this SO question:

  • How to generate event on a specific time of clock in C#?

这应该是相当准确的,但不会是精确到毫秒。

This should be fairly accurate, but won't be exact to the millisecond.

有关第二间隔时间,我会去一个定时器用一个简单的1秒间隔。从用户的角度来看,我认为,如果操作执行在XX有没有很大的差异:XX:xx.000或XX:XX:xx.350

For second intervals, I'd go with a Timer with a simple 1-second-interval. From a user's perspective I think there's not a lot of difference if the action executes at xx:xx:xx.000 or at xx:xx:xx.350.

这篇关于获得一个在C#中的系统时钟变化蜱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆