Skip to content

A lightweight .NET library that implements a consumption-based timer. The timer advances based on a dynamic input percentage.

License

Notifications You must be signed in to change notification settings

designmatters/ScaledTimer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

8 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ScaledTimer

A lightweight .NET library that implements a consumption-based timer. The timer advances based on a dynamic input percentage.

If the scale remains at 100%, it behaves like a regular timer. When the scale fluctuates, this is taken into account. This is useful for tracking the consumption of a resource in terms of time β€” for example, battery usage time in an electric vehicle or RC plane.

πŸš€ Example

var timer = new ScaledTimer.ScaledTimer(intervalMs: 3000, startScale: 50);
timer.Start();
timer.SetScale(73);
...
timer.SetScale(49)
...

[Scale changed β†’ 73%]
β†’ Time: 00:00:00.00
β†’ Time: 00:00:00.37
[Scale changed β†’ 49%]
β†’ Time: 00:00:00.73
β†’ Time: 00:00:00.98
[Scale changed β†’ 89%]
β†’ Time: 00:00:01.23
β†’ Time: 00:00:01.68
[Scale changed β†’ 65%]
β†’ Time: 00:00:02.12
β†’ Time: 00:00:02.45
[Scale changed β†’ 39%]
β†’ Time: 00:00:02.77
β†’ Time: 00:00:02.97
[⏰ Elapsed] Scaled Time: 3.00s | Scale: 39% | Timestamp: 09:34:07.361

About

A lightweight .NET library that implements a consumption-based timer. The timer advances based on a dynamic input percentage.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages