https://github.com/borisgerretzen/pausabletimer
A lightweight C# library that provides a simple timer with the ability to pause and resume.
https://github.com/borisgerretzen/pausabletimer
c-sharp csharp pause timer
Last synced: about 2 months ago
JSON representation
A lightweight C# library that provides a simple timer with the ability to pause and resume.
- Host: GitHub
- URL: https://github.com/borisgerretzen/pausabletimer
- Owner: BorisGerretzen
- License: lgpl-2.1
- Created: 2025-01-29T09:15:40.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-30T11:20:43.000Z (about 1 year ago)
- Last Synced: 2025-06-22T08:47:44.544Z (10 months ago)
- Topics: c-sharp, csharp, pause, timer
- Language: C#
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PausableTimer
[](https://www.nuget.org/packages/PausableTimers/)
A lightweight C# library that provides a simple timer like `System.Timers.Timer` but with the ability to pause and resume.
## Usage
```csharp
using PausableTimers;
// Start a timer with an interval of 5 seconds
var timer = new PausableTimer();
timer.Interval = 5000;
timer.Elapsed += (sender, e) => Console.WriteLine("Elapsed");
timer.Start();
Console.WriteLine("Timer started");
// Wait for 4.5 seconds and pause timer
await Task.Delay(4500);
timer.Pause();
Console.WriteLine("Timer paused");
// Wait for 5 seconds and resume timer
await Task.Delay(5000);
timer.Resume();
Console.WriteLine("Timer resumed");
// Elapsed shows up ~0.5 seconds after resuming, afterwards timer will elapse every 5 seconds
await Task.Delay(6000);
```