PrecisionTimer 2.0.0
dotnet add package PrecisionTimer --version 2.0.0
NuGet\Install-Package PrecisionTimer -Version 2.0.0
<PackageReference Include="PrecisionTimer" Version="2.0.0" />
<PackageVersion Include="PrecisionTimer" Version="2.0.0" />
<PackageReference Include="PrecisionTimer" />
paket add PrecisionTimer --version 2.0.0
#r "nuget: PrecisionTimer, 2.0.0"
#:package PrecisionTimer@2.0.0
#addin nuget:?package=PrecisionTimer&version=2.0.0
#tool nuget:?package=PrecisionTimer&version=2.0.0
PrecisionTimer
Runs at fixed intervals, sleeping rather than spinning where implementation allows.
using PrecisionTime;
using var timer = new PrecisionTimer(1000.0 / 60); // interval in milliseconds
while (running)
{
/* ... */
timer.Wait();
}
How it paces
| Platform | Mechanism |
|---|---|
| Windows 10 1803+ | High-resolution waitable timer |
| Linux, Android | clock_nanosleep to an absolute deadline |
| Everything else | Yield, then spin |
The platform is chosen at run time, so one assembly serves all of them - there is no per-platform package to pick. An import is resolved only when it is called, so the ones belonging to other platforms are never loaded.
Deadlines
Deadlines are absolute and one frame apart, Wait consumes exactly one per call. The time spent not calling Wait leaves the schedule behind
the clock, and the next calls return instantly until it catches up.
Rewind(defaulttrue) - whether those missed deadlines are repaid at all. Turn it off and a late loop simply carries on from now, which is what a frame limiter wants.MaxRewindFrames(default0, meaning no limit) - how many are repaid before the rest are abandoned.Reset()- drop the backlog and aim one frame past the current time. Use it after a pause, a load screen, or anything else that was never meant to count as lateness.
Wait after Dispose throws ObjectDisposedException. An interval shorter than one tick
(0.0001 ms) throws ArgumentOutOfRangeException.
License
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.0.0 | 139 | 9/21/2026 |