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

timersink.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

timersink.net

4.3.1
unpublished
NuGet
Maintainers
0
Source

TimerSink.NET

Nuget

Uses a Stopwatch and PrecisionTimer to track a pool of Tasks and complete them at regular Intervals

The Resolution for events is 1 Millisecond and the TimerSink is capable of honoring it.

TimingSinkItems can be set to wait for the Synchronization Context, The default is ConfigureAwait(false)

Usage

Create a TimingSink

TimingSink tSink = new TimingSink();

Create a TimingSinkItem with ConfigureAwait(false) that will run every 200ms

private void TaskMethod() { // Your Code Here }
TimingSinkItem TaskToTime = new TimingSinkItem(TaskMethod, 200);

Add the TimingSinkItem to the TimingSink

tSink.TimingSinkItems.Add(TaskToTime);

Start the Sink.

tSink.Start();

Examples

Create a TimingSinkItem with ConfigureAwait(false) that will run every 200ms

TimingSinkItem TaskToTime = new TimingSinkItem(TaskMethod, 200);
private void TaskMethod() { }

Create a TimingSinkItem with ConfigureAwait(true)

TimingSinkItem TaskToTimeAwaitUI = new TimingSinkItem(TaskMethodUI, 200, true);
private void TaskMethodUI() { }

Create a TimingSinkItem with ConfigureAwait(true) and throwOnError to catch exceptions

TimingSinkItem TaskToTimeThrowError = new TimingSinkItem(TaskMethodUI, 200, true, true);

Check the Health of the Sink

if(tSink.SinkFaulted){ }

You can view a Full Example on Github

Warning

Your Tasks will execute at the Interval and Execution time is Excluded.

If you place a long running activity into a TimerSinkItem and set the Interval to be shorter than the execution time you will end up with multiple running Tasks

You can use LockedTask.NET to ensure there is only ever one of your Task for long running methods

Keywords

timer

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