Skip to content
ConsoleMonster
Class

ProgressHeartbeat

ConsoleMonster

Namespace
ConsoleMonster
Assembly
ConsoleMonster
Modifiers
sealed
Attributes
Fluent

A progress line for append-only output (CI logs, redirected output, CONSOLEMONSTER_MODE=stream), written every ProgressHeartbeat.Every items or every ProgressHeartbeat.Interval, whichever comes first, so a long quiet run still shows it is alive: Tests: 120/450 (27%) · 3 failed · 01:12. In Azure Pipelines it also moves the task's progress (ContinuousIntegration.ReportProgress); other providers have no progress command. Interactive output draws a live view instead and does not need one.

Inheritance

  • object
  • ProgressHeartbeat

Usage

Explore 13 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.

Accepted by parameters 7

Constructors

public ProgressHeartbeat(string label, Action<string>? write = null, Func<TimeSpan>? clock = null) #

Creates a heartbeat.

Parameters

label string required
What is counted, at the start of the line (for example Tests).
write System.Action<string>? = null optional
Optional sink for complete lines; null writes to standard output through the CI provider's escaping.
clock System.Func<System.TimeSpan>? = null optional
The elapsed-time clock; null uses a stopwatch started now.

Methods

public void Beat(int done, int? total = null, string? detail = null) #

Writes a line now, whether one is due or not (for example when a phase ends).

Parameters

done int required
Items finished.
total int? = null optional
The planned item count, or null while unknown.
detail string? = null optional
Facts to add after the count, or null.
public bool IsDue(int done) #

Whether ProgressHeartbeat.Update would write a line now, so a caller can skip building costly detail.

Parameters

done int required
Items finished.

Returns

bool Whether a line is due.
public string Line(int done, int? total, string? detail, TimeSpan elapsed) #

The line for a count: Label: done/total (percent) · detail · clock.

Parameters

done int required
Items finished.
total int? required
The planned item count, or null.
detail string? required
Facts after the count, or null.
elapsed System.TimeSpan required
The run time.

Returns

string The plain-text line.
public bool Update(int done, int? total = null, string? detail = null) #

Reports progress and writes a line when one is due.

Parameters

done int required
Items finished.
total int? = null optional
The planned item count, or null while unknown.
detail string? = null optional
Facts to add after the count (for example 3 failed), or null.

Returns

bool Whether a line was written.

Properties

public string Label { get; } #

What is counted, at the start of the line.

public int Every { get; set; } #

Writes a line after this many more items (default 0: by time only).

public TimeSpan Interval { get; set; } #

Writes a line when this much time passed since the last one (default 30 seconds; zero: by count only).

public GlyphTier? Glyphs { get; set; } #

The glyph tier of the separators, or null (default) for the current terminal profile's tier.

public int Beats { get; private set; } #

Lines written so far.

Extension Methods

public static ProgressHeartbeat Every(ProgressHeartbeat progressHeartbeat, int value) #

Sets ProgressHeartbeat.Every: Writes a line after this many more items (default 0: by time only).

Parameters

progressHeartbeat ConsoleMonster.ProgressHeartbeat required
The instance.
value int required
The value.

Returns

ProgressHeartbeat The same instance.

Examples

// C# initializer or property       // C# fluent
progressHeartbeat.Every = value;    progressHeartbeat.Every(value);
public static ProgressHeartbeat Glyphs(ProgressHeartbeat progressHeartbeat, GlyphTier? value) #

Sets ProgressHeartbeat.Glyphs: The glyph tier of the separators, or null (default) for the current terminal profile's tier.

Parameters

progressHeartbeat ConsoleMonster.ProgressHeartbeat required
The instance.
value ConsoleMonster.Capabilities.GlyphTier? required
The value.

Returns

ProgressHeartbeat The same instance.

Examples

// C# initializer or property        // C# fluent
progressHeartbeat.Glyphs = value;    progressHeartbeat.Glyphs(value);
public static ProgressHeartbeat Interval(ProgressHeartbeat progressHeartbeat, TimeSpan value) #

Sets ProgressHeartbeat.Interval: Writes a line when this much time passed since the last one (default 30 seconds; zero: by count only).

Parameters

progressHeartbeat ConsoleMonster.ProgressHeartbeat required
The instance.
value System.TimeSpan required
The value.

Returns

ProgressHeartbeat The same instance.

Examples

// C# initializer or property          // C# fluent
progressHeartbeat.Interval = value;    progressHeartbeat.Interval(value);