Which timers are dependent on system time?

后端 未结 2 1537
我寻月下人不归
我寻月下人不归 2021-01-04 05:19

I haven\'t tested this yet. I am hoping someone already knows the answer, so I don\'t have to write a test application, otherwise I will. :)

Usually when I want to c

2条回答
  •  醉话见心
    2021-01-04 06:12

    I was trying to solve similar problem. I turn out to use System.Diagnostic.StopWatch to replace all DateTime.Now. StopWatch will use the high frequency clock if present. So, it's more accurate and independent of the system clock change. However, if high frequency clock is not present, it will fall back to use system clock again.

    According to my testing, all my machines have high frequency clock, including the machines in VM.

    About the Timer, as far as I remember, it isn't dependent on the system clock. However, you don't really want to use Timer to track the time because the Timer callback events may be deferred by some other events.

提交回复
热议问题