Skip to content
ConsoleMonster
Class

RunTracker

ConsoleMonster.Live

Namespace
ConsoleMonster.Live
Assembly
ConsoleMonster
Modifiers
sealed

The state of a run of many items (ConsoleRun, Invoke-ConsoleRun), safe to update from any thread: each item is pending, running or finished with an outcome; failures keep their message. RunView draws it.

Inheritance

  • object
  • RunTracker

Usage

Explore 5 API references to this type

This type appears in these public API surfaces even when no hand-authored example is attached directly to the page.

Returned or exposed by 1

Accepted by parameters 4

Constructors

RunTracker 2 overloads
public RunTracker(int total, Func<TimeSpan>? clock = null) #

Creates a tracker.

Parameters

total int required
The number of items.
clock System.Func<System.TimeSpan>? = null optional
The run clock, or null for a stopwatch started now.
public RunTracker(IEnumerable<RunItem> items, Func<TimeSpan>? clock = null) #

Creates a tracker with a fixed declaration of names, targets and categories for queued work.

Parameters

items System.Collections.Generic.IEnumerable<ConsoleMonster.Live.RunItem> required
Items in input order; their position is the update key.
clock System.Func<System.TimeSpan>? = null optional
Optional monotonic clock, used by deterministic captures and embedded hosts.

Methods

public int Add() #

Adds a pending item to a count-based run whose work is discovered incrementally.

Returns

int The new item's zero-based index.

Exceptions

  • InvalidOperationException – The run has already finished or has a fixed declaration of named items.
public void Complete() #

The run ended: items never started count as skipped and the clock stops.

public void Finished(int index, StatusKind outcome, string label, string? message = null, bool timedOut = false) #

An item finished.

Parameters

index int required
The item's position (0-based).
outcome ConsoleMonster.Styling.StatusKind required
Pass, Fail, Warn, Skip, Error, Investigate or NotRun.
label string required
Its label (for the failures list).
message string? = null optional
The error message of a failed item, or null.
timedOut bool = false optional
Whether it ran out of time.
public RunItemSnapshot? FinishItem(int index, StatusKind outcome, string? message = null, TimeSpan? duration = null, bool timedOut = false) #

Completes a declared item exactly once, retaining its message and duration.

Parameters

index int required
Zero-based input position.
outcome ConsoleMonster.Styling.StatusKind required
Pass, Fail, Warn, Skip, Error, Investigate or NotRun.
message string? = null optional
Full literal completion message.
duration System.TimeSpan? = null optional
Explicit duration, or null to use the running clock.
timedOut bool = false optional
Whether the item's failure was a timeout.

Returns

RunItemSnapshot? The new completion, or null if it was already completed.
public void Retrying(int index, string label, int attempt) #

A running item failed and starts another attempt; it stays running and counts as retried.

Parameters

index int required
The item's position (0-based).
label string required
Its label.
attempt int required
The attempt about to start (2 for the first retry).
public RunSnapshot Snapshot() #

A consistent copy of the state, for drawing on another thread.

Returns

RunSnapshot The snapshot.
public void Started(int index, string label) #

An item started.

Parameters

index int required
The item's position (0-based).
label string required
Its label.
public bool StartItem(int index, string? phase = null) #

Starts a declared item or updates its phase. Finished items cannot restart.

Parameters

index int required
Zero-based input position.
phase string? = null optional
Literal phase text.

Returns

bool False for an already finished item or completed run.

Properties

public int Total { get; } #

The number of items.