PrecisionTimer.NET
2.4.0.3
See the version list below for details.
dotnet add package PrecisionTimer.NET --version 2.4.0.3
NuGet\Install-Package PrecisionTimer.NET -Version 2.4.0.3
<PackageReference Include="PrecisionTimer.NET" Version="2.4.0.3" />
paket add PrecisionTimer.NET --version 2.4.0.3
#r "nuget: PrecisionTimer.NET, 2.4.0.3"
// Install PrecisionTimer.NET as a Cake Addin
#addin nuget:?package=PrecisionTimer.NET&version=2.4.0.3
// Install PrecisionTimer.NET as a Cake Tool
#tool nuget:?package=PrecisionTimer.NET&version=2.4.0.3
High Precision/High Resolution Timer for .NET Standard and Greater
PrecisionTimer.NET
callbacks can run at 1ms
on platforms that allow it.
using PrecisionTiming;
Basic Usage
public static PrecisionTimer MyTimer = new();
Using Precision Timer is as simple as using any other Windows Timer.
MyTimer.SetInterval(SomeAction, Interval);
Start the Timer
MyTimer.Start();
Check if the Timer is Running
MyTimer.IsRunning();
Stop the Timer
MyTimer.Stop();
Dispose the Timer
MyTimer.Dispose();
SetInterval / Configure
If you use SetInterval
to set only Action
and Interval
the timer will automatically start with the most common defaults, but it has several optional parameters you can change
For example, If you don't want the timer to start automatically then use the following
MyTimer.SetInterval(SomeAction, Interval, false);
You can use Configure
instead of SetInterval
if you prefer
MyTimer.Configure(SomeAction, Interval, false);
Manual Setup
You can manually configure the Timer
and then Start
it yourself instead of using SetInterval
SetAction
Sets the Action
that will be triggered by the TimerCallback when the Period
has elapsed
MyTimer.SetAction(Action);
Periodic Timers
must stop before setting.
SetPeriod / SetInterval(int)
Sets the Period (Interval) between Actions
in Milliseconds
.
MyTimer.SetPeriod(int);
MyTimer.GetPeriod();
Both Timer Modes
must stop before setting.
SetResolution
Set the Resolution
of the Timer before you start the timer
MyTimer.Start(int);
The resolution is in milliseconds, The default resolution for SetInterval(Action)
is 0
The Resolution
increases with smaller values.
A resolution of 0 indicates periodic events should occur with the greatest possible accuracy.
To reduce system overhead, however, you should use the maximum value appropriate for your application.
The normal Resolution of a .Net Timer is around 12-15ms
SetEventArgs
Set EventArgs
of the Timer
MyTimer.SetEventArgs(EventArgs);
MyTimer.GetEventArgs();
Periodic Timers
must stop before setting.
SetAutoResetMode
Set the Periodic/OneShot Mode of the <see cref="PrecisionTimer"/>
MyTimer.SetAutoResetMode(bool);
MyTimer.GetAutoResetMode();
True
if the PrecisionTimer
should raise the Ticks
Event each time the interval elapses. (Periodic)
False
if the PrecisionTimer
should raise the event only once AFTER the first time the interval elapses. (One-Shot)
Both Timer Modes
must stop before setting.
Timing Settings
Global Multimedia Timer settings that affect your application
Set the Applications Minimum Resolution
PrecisionTimerSettings.SetMinimumTimerResolution(0);
Clear the Applications Minimum Resolution
PrecisionTimerSettings.ClearMinimumTimerResolution(0);
Multimedia Timer
Precision Timer.NET is a Multimedia Timer.
You can read more about Multimedia Timers on MSDN
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on PrecisionTimer.NET:
Package | Downloads |
---|---|
Metronome.NET
A low cpu callback that runs an Action or Task at sub-ms speeds as a pulsing metronome |
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on PrecisionTimer.NET:
Repository | Stars |
---|---|
Valkirie/HandheldCompanion
ControllerService
|
|
catright/Wale
Windows Audio Loudness Equalizer
|