-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Description
System.Threading.Timer
https://docs.microsoft.com/en-us/dotnet/api/system.threading.timer?view=net-6.0
The Timer class has the same resolution as the system clock. This means that if the period is less than the resolution of the system clock, the TimerCallback delegate will execute at intervals defined by the resolution of the system clock, which is approximately 15 milliseconds on Windows 7 and Windows 8 systems.
Task.Delay
https://docs.microsoft.com/en-us/dotnet/api/system.threading.tasks.task.delay?view=net-6.0
This method depends on the system clock. This means that the time delay will approximately equal the resolution of the system clock if the millisecondsDelay argument is less than the resolution of the system clock, which is approximately 15 milliseconds on Windows systems.
This is not true (on windows) both of them doesn't respect system timer resolution below 15 milliseconds. After timeBeginPeriod(1)
or NtSetTimerResolution(5000, true, out _)
the resolution of System.Threading.Timer
and Task.Delay
still remains ~15 milliseconds :(