Icod.Timing
1.0.0
dotnet add package Icod.Timing --version 1.0.0
NuGet\Install-Package Icod.Timing -Version 1.0.0
<PackageReference Include="Icod.Timing" Version="1.0.0" />
<PackageVersion Include="Icod.Timing" Version="1.0.0" />
<PackageReference Include="Icod.Timing" />
paket add Icod.Timing --version 1.0.0
#r "nuget: Icod.Timing, 1.0.0"
#:package Icod.Timing@1.0.0
#addin nuget:?package=Icod.Timing&version=1.0.0
#tool nuget:?package=Icod.Timing&version=1.0.0
Icod.Timing
Icod.Timing is a small, command-neutral .NET library for monotonic elapsed-time
measurement, cancellable delays, and drift-resistant periodic scheduling.
The library deliberately does not own civil or calendar time. Date parsing,
formatting, time zones, local/UTC wall clocks, and system-clock administration
belong in domain-specific libraries. Icod.Timing is concerned with questions
such as "how much time has elapsed?", "wait for this duration", and "run again at
this fixed cadence."
What the library provides
IMonotonicClockabstracts monotonic timestamp observation, elapsed-time calculation, and cancellable delays.SystemMonotonicClockusesStopwatchfor elapsed-time measurement and rechecks long delays in bounded slices so wall-clock adjustments cannot change the requested elapsed duration.PeriodicTickdescribes one fixed-rate scheduling observation, including its logical schedule sequence, scheduled elapsed time, observed elapsed time, and lateness.PeriodicMissedTickPolicymakes overdue-tick behavior explicit. The defaultSkipMissedpolicy advances to the most recent schedule position that is already due;CatchUpemits each overdue position in sequence.IPeriodicSchedulersupplies cancellable fixed-rate periodic ticks.MonotonicPeriodicSchedulerschedules against elapsed time from a monotonic clock instead of repeatedly delaying from the previous tick, avoiding cumulative drift.
When SkipMissed is used, PeriodicTick.Sequence is the logical fixed-rate
schedule sequence and can therefore jump when one or more overdue ticks are
discarded.
Basic use
using Icod.Timing;
IMonotonicClock clock = SystemMonotonicClock.Instance;
long started = clock.GetTimestamp();
await clock.DelayAsync( TimeSpan.FromMilliseconds( 250 ) );
TimeSpan elapsed = clock.GetElapsedTime(
started,
clock.GetTimestamp()
);
await foreach ( PeriodicTick tick in MonotonicPeriodicScheduler.Instance.ScheduleAsync(
TimeSpan.FromSeconds( 1 ),
fireImmediately: true,
missedTickPolicy: PeriodicMissedTickPolicy.SkipMissed
) ) {
Console.WriteLine(
$"tick {tick.Sequence}: scheduled={tick.ScheduledElapsed}, late={tick.Lateness}"
);
}
Intended consumers
The package is suitable for utility suites, terminal libraries, services, networking code, retry/backoff infrastructure, test runners, monitoring tools, and other applications that need elapsed-time or fixed-cadence behavior without taking a dependency on a command framework.
Typical consumers include timeout enforcement, tail -f polling, progress
reporting, refresh loops, input ambiguity windows, health checks, keepalives,
rate limiting, and periodic sampling.
Sample
Icod.Timing.Sample demonstrates elapsed-time measurement, cancellable delay,
fixed-rate scheduling, and skipped-tick behavior with the system clock.
dotnet run --project samples/Icod.Timing.Sample/Icod.Timing.Sample.csproj
Build and test
Icod.Timing targets .NET 7.0, 8.0, 9.0, and 10.0 and uses C# 13.
dotnet build Icod.Timing.sln
dotnet test Icod.Timing.sln
The repository contains the library project at the root, a sample under
samples/Icod.Timing.Sample, and its test project under tests/Timing.Tests.
Author and copyright
Author: Timothy J. Bruce uniblab@hotmail.com
Copyright (c) 2026 Timothy J. Bruce
License
Icod.Timing is licensed under the GNU Lesser General Public License, version
3.0 or later. See LICENSE.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- No dependencies.
-
net7.0
- No dependencies.
-
net8.0
- No dependencies.
-
net9.0
- No dependencies.
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Icod.Timing:
| Package | Downloads |
|---|---|
|
Icod.Terminal
Managed, cross-platform live-terminal session, endpoint, mode, input, lifecycle, and terminal-control foundation for .NET. |
|
|
Icod.Processes
Cross-platform .NET process execution and control primitives for safe child launching, process identity, signals, priorities, liveness, waiting, cancellation, and timeouts. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.0.0 | 3,608 | 8/25/2026 |
Initial standalone monotonic timing and periodic scheduling release.