High Resolution Timer for .NET Core. Uses Waitable Timer on Windows, timerfd on Linux, and kqueue on macOS, all with sub-millisecond precision.
$ dotnet add package Haukcode.HighResolutionTimerA cross-platform, high-resolution timer for .NET Standard 2.0+ with precise timing for Windows, Linux, and macOS.
dotnet add package Haukcode.HighResolutionTimer
using Haukcode.HighResolutionTimer;
// Create a 10ms period timer (100 Hz)
using (var timer = new HighResolutionTimer())
{
timer.SetPeriod(10); // Set period in milliseconds
timer.Start();
for (int i = 0; i < 100; i++)
{
timer.WaitForTrigger(); // Wait for next tick
// Your periodic code here
}
timer.Stop();
}
timer.SetPeriod(16.67))For detailed documentation, examples, and API reference, visit: https://github.com/HakanL/Haukcode.HighResolutionTimer
MIT License - See LICENSE
38.1K