ProgressHeartbeat
ConsoleMonster
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.
Returned or exposed by 6
- Extension method ProgressHeartbeat.Every
- Extension method ProgressHeartbeat.Glyphs
- Extension method ProgressHeartbeat.Interval
- Method ProgressHeartbeatFluent.Every
- Method ProgressHeartbeatFluent.Glyphs
- Method ProgressHeartbeatFluent.Interval
Accepted by parameters 7
- Extension method ProgressHeartbeat.Every
- Extension method ProgressHeartbeat.Glyphs
- Extension method ProgressHeartbeat.Interval
- Method ProgressHeartbeatFluent.Every
- Method ProgressHeartbeatFluent.Glyphs
- Method ProgressHeartbeatFluent.Interval
- Method TestRunText.Heartbeat
Constructors
public ProgressHeartbeat(string label, Action<string>? write = null, Func<TimeSpan>? clock = null) #Creates a heartbeat.
Parameters
- label string
- What is counted, at the start of the line (for example Tests).
- write System.Action<string>? = null
- Optional sink for complete lines; null writes to standard output through the CI provider's escaping.
- clock System.Func<System.TimeSpan>? = null
- 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
- Items finished.
- total int? = null
- The planned item count, or null while unknown.
- detail string? = null
- 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
- 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
- Items finished.
- total int?
- The planned item count, or null.
- detail string?
- Facts after the count, or null.
- elapsed System.TimeSpan
- 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
- Items finished.
- total int? = null
- The planned item count, or null while unknown.
- detail string? = null
- Facts to add after the count (for example 3 failed), or null.
Returns
bool Whether a line was written.Inherited Methods
Properties
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.
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
- The instance.
- value int
- The value.
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
- The instance.
- value ConsoleMonster.Capabilities.GlyphTier?
- The value.
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
- The instance.
- value System.TimeSpan
- The value.
Examples
// C# initializer or property // C# fluent
progressHeartbeat.Interval = value; progressHeartbeat.Interval(value);