Icod.Timing 1.0.0

dotnet add package Icod.Timing --version 1.0.0
                    
NuGet\Install-Package Icod.Timing -Version 1.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Icod.Timing" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Icod.Timing" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Icod.Timing" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Icod.Timing --version 1.0.0
                    
#r "nuget: Icod.Timing, 1.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Icod.Timing@1.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Icod.Timing&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Icod.Timing&version=1.0.0
                    
Install as a Cake Tool

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

  • IMonotonicClock abstracts monotonic timestamp observation, elapsed-time calculation, and cancellable delays.
  • SystemMonotonicClock uses Stopwatch for elapsed-time measurement and rechecks long delays in bounded slices so wall-clock adjustments cannot change the requested elapsed duration.
  • PeriodicTick describes one fixed-rate scheduling observation, including its logical schedule sequence, scheduled elapsed time, observed elapsed time, and lateness.
  • PeriodicMissedTickPolicy makes overdue-tick behavior explicit. The default SkipMissed policy advances to the most recent schedule position that is already due; CatchUp emits each overdue position in sequence.
  • IPeriodicScheduler supplies cancellable fixed-rate periodic ticks.
  • MonotonicPeriodicScheduler schedules 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: 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • 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.