Why are .NET timers limited to 15 ms resolution?

后端 未结 3 1859
一生所求
一生所求 2020-11-22 05:05

Note that I\'m asking about something that will call a callback function more often than once every 15 ms using something like System.Threading.Timer. I\'m not

3条回答
  •  长发绾君心
    2020-11-22 05:45

    Perhaps the document linked here explains it a bit. It's kinda dry so I only browsed it quickly :)

    Quoting the intro:

    The system timer resolution determines how frequently Windows performs two main actions:

    • Update the timer tick count if a full tick has elapsed.
    • Check whether a scheduled timer object has expired.

    A timer tick is a notion of elapsed time that Windows uses to track the time of day and thread quantum times. By default, the clock interrupt and timer tick are the same, but Windows or an application can change the clock interrupt period.

    The default timer resolution on Windows 7 is 15.6 milliseconds (ms). Some applications reduce this to 1 ms, which reduces the battery run time on mobile systems by as much as 25 percent.

    Originally from: Timers, Timer Resolution, and Development of Efficient Code (docx).

提交回复
热议问题