Skip to content
ConsoleMonster
Class

ConsoleRun

ConsoleMonster.Live

Namespace
ConsoleMonster.Live
Assembly
ConsoleMonster
Modifiers
static

Runs work over many items with a live view of the run (the C# side of Invoke-ConsoleRun).

Inheritance

  • object
  • ConsoleRun

Methods

ForEachAsync``2 2 overloads
public static Task<IReadOnlyList<RunResult<TItem?, TResult?>>> ForEachAsync<TItem, TResult>(IEnumerable<TItem?> items, Func<TItem?, CancellationToken, Task<TResult?>> body, Action<RunOptions> configure, CancellationToken cancellationToken = default) #

Configures a fresh run request before executing the existing item-run pipeline.

Type Parameters

TItem
The item type.
TResult
The result type.

Parameters

items System.Collections.Generic.IEnumerable<TItem?> required
The input items.
body System.Func<TItem?, System.Threading.CancellationToken, System.Threading.Tasks.Task<TResult?>> required
The work.
configure System.Action<ConsoleMonster.Live.RunOptions> required
Run settings.
cancellationToken System.Threading.CancellationToken = default optional
Cancellation.

Returns

Task<IReadOnlyList<RunResult<TItem?, TResult?>>> The ordered run results.
public static async Task<IReadOnlyList<RunResult<TItem?, TResult?>>> ForEachAsync<TItem, TResult>(IEnumerable<TItem?> items, Func<TItem?, CancellationToken, Task<TResult?>> body, RunOptions? options = null, CancellationToken cancellationToken = default) #

Runs body for every item, at most RunOptions.ThrottleLimit at a time, showing the run (summary line, item cells, running items, failures; one line per item when the output is not interactive). An item that throws, or runs past RunOptions.Timeout, counts as failed and the run goes on; cancelling stops starting new items, cancels the running ones and counts the rest as skipped.

Type Parameters

TItem
The item type.
TResult
The result type.

Parameters

items System.Collections.Generic.IEnumerable<TItem?> required
The items.
body System.Func<TItem?, System.Threading.CancellationToken, System.Threading.Tasks.Task<TResult?>> required
The work for one item; observe the token for timeouts and cancellation.
options ConsoleMonster.Live.RunOptions? = null optional
Options, or null for the defaults.
cancellationToken System.Threading.CancellationToken = default optional
Stops the run.

Returns

Task<IReadOnlyList<RunResult<TItem?, TResult?>>> One result per item, in input order (items never started are left out).