PrecisionTimer 2.0.0

dotnet add package PrecisionTimer --version 2.0.0
                    
NuGet\Install-Package PrecisionTimer -Version 2.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="PrecisionTimer" Version="2.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="PrecisionTimer" Version="2.0.0" />
                    
Directory.Packages.props
<PackageReference Include="PrecisionTimer" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add PrecisionTimer --version 2.0.0
                    
#r "nuget: PrecisionTimer, 2.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package PrecisionTimer@2.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=PrecisionTimer&version=2.0.0
                    
Install as a Cake Addin
#tool nuget:?package=PrecisionTimer&version=2.0.0
                    
Install as a Cake Tool

PrecisionTimer

CI

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 (default true) - 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 (default 0, 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

MIT

Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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