🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

precisiontimer.net

Package Overview
Dependencies
Maintainers
0
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install
Package was removed
Sorry, it seems this package was removed from the registry

precisiontimer.net

3.0.0.7
unpublished
NuGet
Maintainers
0
Source

Nuget

High Precision/High Resolution Timer that can safely achieve 1ms callbacks

Using a Precision Timer is as simple as using any other Windows Timer

using PrecisionTiming;

public static PrecisionTimer MyTimer = new PrecisionTimer();

Basic Usage

Set Action and Interval and start the Precision Timer

MyTimer.SetInterval(SomeAction, Interval);

Check if the Precision Timer is Running

MyTimer.IsRunning();

You can call SetInterval again to change the Action

MyTimer.SetInterval(SomeDifferentAction, Interval);

Stop the Precision Timer

MyTimer.Stop();

Start the Precision Timer Manually

MyTimer.Start();

Dispose the Precision Timer

MyTimer.Dispose();

SetInterval / Configure

If you use SetInterval to set only Action and Interval the Precision Timer will automatically start with the most common defaults, but it has several optional parameters you can change

s

For example, If you don't want the Precision 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 Precision 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.

One Shot Timers can change between shots, It is safer to stop.

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 Precision Timer before you start

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 Precision Timer

MyTimer.SetEventArgs(EventArgs);
MyTimer.GetEventArgs();

Periodic Timers must stop before setting.

One Shot Timers can change between shots, It is safer to stop.

SetAutoResetMode

Set the Periodic/OneShot Mode of the Precision Timer

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.

Copyright S Christison ©2020-2024

Keywords

safe

FAQs

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts