开发者

Monotonic WaitableTimer in C#

Is there a Monotonic WaitableTimer available in C#, or even in Win32 that I could wrap?

Currently I'm using the Win32 CreateWaitableTimer, but if the system clock gets modified it will skew the timer values and cause things to happen before or after they are scheduled to occur.

The only Monotonic cl开发者_开发技巧ock source I've found available in Windows XP is GetTickCount(), but I was hoping to not have to write my own timer using this.


SetWaitableTimer() supports two ways to set the due time. A positive value sets absolute time, it will be affected by the clock. A negative value sets relative time, it will not be affected by the clock. You want the latter.

Any .NET timer will not be affected by the clock. Not even the time zone or DateTime.Now changes. Check out CultureInfo.ClearCachedData(). Using System.Threading.Timer ought to be a good managed replacement.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜