What is the maximum precision of the Timer in .NET?

后端 未结 6 2069
北荒
北荒 2020-12-20 14:12

I\'m wondering what the precision of the Timer class is in System.Timers, because it\'s a double (which would seem to indicate that you can have fractions of milliseconds).

6条回答
  •  误落风尘
    2020-12-20 14:47

    I compared System.Timers.Timer and System.Threading.Timer - both of them give systematic errors around 8..16 ms, especially on small intervals (1000..6000 ms). Each subsequent call of timer routine occurred with increased interval from first call. For example, timer with 2000 ms interval fires in 2000, 4012, 6024, 8036, 10048 milliseconds and so on (Timestamps obtained from Environment.TickCount and Stopwatch.ElapsedTicks, both give same results).

提交回复
热议问题