Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
11 Commits
 
 
 
 
 
 
 
 

Repository files navigation

WatchdogDotNet

A watchdog timer for .NET. This simply adds the extension method Restart() to System.Timer. Should you download and use the NuGet package? Probably not. It's so thin, there's no reason to. Just copy the source file to your project.

Usage

Remember, Timer is IDisposable. You'll likely not use a using block, so make sure to dispose of it. For things like what is in the ElapsedEventArgs, see the Microsoft documentation.

TimeSpan timeout = TimeSpan.FromMinutes(10);
using (var watchdog = new Timer(timeout.TotalMilliseconds()))
{
      watchdog.AutoReset = false; // Often, you want to handle the problem only once. 
      watchdog.Elapsed += (s, e) => { RecoverFromCatastrophe() };
      // do stuff
      watchdog.Restart(); // kick the dog
      // do more stuff
      watchdog.Restart(); // kick the dog
      // etc.
}

Targets / Requirements

The earliest implementations of System.Timer are in the .NET Framework v3.5 and in .NET Standard 2.0, so these are the lowest targets you can use.

About

A watchdog timer for .NET

Resources

Stars

Watchers

Forks

Releases

Packages

Used by

Contributors

Languages

Morty Proxy This is a proxified and sanitized view of the page, visit original site.