Skip to content
ConsoleMonster

Worker progress

Follow eight simulated workers with progress lanes, a throughput trend and a bounded work queue.

Demos Dashboards

Use it when a worker queue needs progress bars and a throughput trend.

  • Live
  • 88×28
  • PowerShell 7.4+
  • .NET 8.0+
Worker progress 88×2824-bitFull

How it's built

The whole program in one file, with its sample data at the top. It drew the recording above; both languages draw the same cells.

PowerShellworker-progress.ps1View on GitHub
# Animate worker progress bars and a small session dashboard.
[CmdletBinding()]
param(
    [switch] $StaticSnapshot,
    [ValidateRange(0, 4)] [int] $Step = 0
)

Import-Module ConsoleMonster
# All data is synthetic and inline; no services are contacted or changed.
# All values are synthetic. This example never connects to a host.

# Data: fictional inputs kept in memory.
$workerCount = 8

# Layout: construct the widgets shown on screen.
function New-DemoFrame($Tick) {
    New-ConsoleRows -Gap 1 {
        '[bold]Worker stress dashboard[/] [muted]· worker pool[/]'
        New-ConsoleColumns {
            New-ConsolePanel -Title Workers {
                foreach ($worker in 1..$workerCount) {
                    $value = [Math]::Min(100, 12 + $worker * 5 + $Tick * 17)
                    New-ConsoleProgress -Name ('worker' + $worker) -Label ('worker-{0:00}' -f $worker) -Value $value -Total 100
                }
            }
            New-ConsolePanel -Title Session {
                New-ConsoleKeyValue -Markup -Data ([ordered] @{
                    'Updates' = [string] (800 + $Tick * 320)
                    'Queue' = [string] (24 - $Tick * 5)
                    'Workers' = '8'
                    'Dropped' = '[pass]0[/]'
                })
                New-ConsoleSparkline -Label 'updates/s' -Value @(120,180,160,240,210,(220 + $Tick * 15))
            }
        }
        '[muted]Ctrl+C stops the live run.[/]'
    }
}

# Live updates: print one state headlessly, or run the bounded simulation.
if ($StaticSnapshot -or [Console]::IsInputRedirected) {
    New-DemoFrame $Step | Write-ConsoleWidget
    return
}
$frames = @(0..4 | ForEach-Object { New-DemoFrame $_ })
$screen = New-ConsoleRegion -Name demo -Widget $frames[0]
Start-ConsoleDashboard $screen -ArgumentList (, $frames) {
    param($Frames)
    foreach ($frame in $Frames) {
        if ($ConsoleSession.Cancellation.IsCancellationRequested) { break }
        Set-ConsoleRegion -Name demo -Widget $frame
        Start-Sleep -Milliseconds 650
    }
}
C#Program.csView on GitHub
// Animate worker progress bars and a small session dashboard.
// All data is synthetic and inline; no services are contacted or changed.
using ConsoleMonster;
using ConsoleMonster.Layout;
using ConsoleMonster.Live;
using ConsoleMonster.Widgets;

// All values are synthetic. This example never connects to a host.

// Data: fictional inputs kept in memory.
int workerCount = 8;

// Run options: redirected input selects a deterministic snapshot.
bool snapshot = args.Contains("--snapshot") || (!args.Contains("--interactive") && Console.IsInputRedirected);
int stepAt = Array.IndexOf(args, "--step");
int step = stepAt < 0 ? 0 : int.Parse(args[stepAt + 1], System.Globalization.CultureInfo.InvariantCulture);
if (step < 0 || step > 4) throw new ArgumentOutOfRangeException(nameof(step));

// Layout: construct the widgets shown on screen.
IWidget Frame(int tick) {
    Rows workers = new Rows();
    for (int worker = 1; worker <= workerCount; worker++) {
        string name = "worker-" + worker.ToString("00", System.Globalization.CultureInfo.InvariantCulture);
        workers.Add(new ProgressBar(name, name)
            .WithValue(Math.Min(100, 12 + worker * 5 + tick * 17)).WithTotal(100));
    }
    KeyValueList stats = new KeyValueList()
        .Add("Updates", (800 + tick * 320).ToString(System.Globalization.CultureInfo.InvariantCulture))
        .Add("Queue", (24 - tick * 5).ToString(System.Globalization.CultureInfo.InvariantCulture))
        .Add("Workers", "8").Add("Dropped", "[pass]0[/]");
    Sparkline trend = new Sparkline { Label = "updates/s" };
    trend.AddRange(new double[] { 120,180,160,240,210,220 + tick * 15 });
    return new Rows(new TextBlock("[bold]Worker stress dashboard[/] [muted]· worker pool[/]"),
        new Columns(new Panel(workers, "Workers"), new Panel(new Rows(stats, trend), "Session")),
        new TextBlock("[muted]Ctrl+C stops the live run.[/]")) { Gap = 1 };
}

// Live updates: print one state headlessly, or run the bounded simulation.
if (snapshot) {
    Terminal.Write(Frame(step));
    return;
}
Slot screen = new Slot("demo", Frame(0));
using LiveSession session = new LiveSession(screen);
session.Run(live => {
    for (int tick = 0; tick <= 4 && !live.Cancellation.IsCancellationRequested; tick++) {
        screen.Handle(live).Set(Frame(tick));
        if (live.Cancellation.WaitHandle.WaitOne(650)) break;
    }
});

Run it yourself

Three steps in PowerShell, four in C#. Every command copies with one click.

  1. Install the module

    Once. Windows PowerShell 5.1 or PowerShell 7 on Windows, macOS or Linux.

    Install-Module ConsoleMonster -Scope CurrentUser
  2. Save the program

    Download it, or copy it from above into worker-progress.ps1.

  3. Run it

    From the folder you saved it in.

    ./worker-progress.ps1
  1. Create a project

    A plain console app; .NET 8 or later.

    dotnet new console -n Workerprogress; cd Workerprogress
  2. Add ConsoleMonster

    The only package the program needs.

    dotnet add package ConsoleMonster
  3. Replace Program.cs

    Download it, or copy the program from above.

  4. Run it

    dotnet run

Or skip the copying. Every demo ships with the module and the project template.

Show-ConsoleDemo worker-progress
Get-ConsoleDemo worker-progress -Path ./worker-progress.ps1
dotnet new install ConsoleMonster.Templates
dotnet new consolemonster --demo worker-progress -n Workerprogress

Make it yours

Start with these, then read the rest of the file.

  1. Replace the eight simulated workers with your queue.

  2. Feed the sparkline measured update rates.

  3. Choose queue and error thresholds.

More dashboards

All demos