Skip to footer content
Iron Academy Logo
C# Application
C# Application

Other Categories

Live Progress Bars - Spectre Console Series

Tim Corey
7m 04s

The Spectre.Console library is all about turning ordinary C# console applications into visually appealing, informative tools. One of its most striking features is the ability to show progress bars that update as your application works. This is extremely helpful for long-running tasks where you want to keep the user informed.

In his "Live Progress Bars – Spectre Console Series" video, Tim Corey shows how to create a C# Spectre Console progress bar step by step.

Setting Up the Console Application

At the beginning of the video (0:00) Tim introduces the Spectre.Console console library and shows that the source code link is available under the video. He reminds viewers that these are 10-minute chunks you can fit into your day.

Tim is working in a normal C# console app — think of a simple boilerplate file with class Program and static void Main(string[] args). He’s not using any special UI framework, just a NuGet package reference to Spectre.Console. This is a good reminder that you can bring these features into any Windows Terminal or console host.

Creating the Progress Context

At 0:34 Tim begins coding. In his Main method, he calls AnsiConsole.Progress() and then .Start() on it. This is the standard entry point for a progress bar in Spectre.Console.

He shows that you pass a lambda with a context parameter, which you can think of as async ctx when you later make it asynchronous. Inside this context you define your tasks. This is the Spectre.Console equivalent of setting up your progress tasks before you start updating them.

Adding Progress Tasks

Tim creates three progress tasks:

  • “Downloading Data”

  • “Installing Application”

  • “Data Cleanup”

Each is added with var task = context.AddTask("…"). These return task handles you can later increment. Tim notes (1:22) that he’s only scratching the surface—Spectre.Console supports different styles, columns, and layouts, such as adding a new ProgressBarColumn, new PercentageColumn, new SpinnerColumn, or new TaskDescriptionColumn to customize how your bar looks.

He likens the tasks to Visual Studio’s installer: downloading, installing, then cleaning up (1:42). You could imagine each task holding an int percent or int value internally as you update it.

Updating the Progress Bars

At 1:50 Tim sets up a while loop to run until the context is finished. In a real C console program you might write while (!context.IsFinished) or while (context.IsFinished == false) inside your Main method.

Inside the loop, he calls Thread.Sleep(500) to slow things down (2:15). He then calls task.Increment() with a random double multiplied by a max value (2:29, 2:47). This simulates work being done.

He updates task one and task two at different speeds, and for task three he adds an if check (3:05) so that it only starts after task two’s percentage is greater than 80. This is essentially controlling dependencies between progress tasks.

Although Tim doesn’t literally type int i in a foreach loop, you can imagine using one to iterate over tasks and call .Increment(int) for each. In production you might have real data, such as a var client downloading files, or a string filename being processed. Tim keeps it simple with random numbers to show the display.

Displaying and Observing the Progress Bars

At 3:47 Tim runs the console application. The progress bars appear stacked. Each bar shows a percentage at the end, turning green when complete (4:01). Once the first tasks are done, “Data Cleanup” begins.

At 4:14 Tim points out that the cursor returns to the bottom of the console, a small but important usability detail. The Spectre.Console progress bar automatically formats the status and keeps everything in place without flickering.

Going Asynchronous with Await Task

At 4:36 Tim switches gears to show an asynchronous version. He changes .Start() to .StartAsync() and marks the lambda async. Now the context parameter behaves like async ctx.

Inside, instead of Thread.Sleep he uses await Task.Delay(500) (4:58). This yields control back to the system while waiting. In a real program you might be awaiting a real operation, such as await client.DownloadAsync() or await AnsiConsole.MarkupAsync() to print status text alongside the bar.

The async version works exactly the same way visually (5:16–5:23), but is better suited for modern async workflows. Tim doesn’t show it, but you could also capture exceptions with try/catch (Exception ex) around your awaited tasks.

Spectre Console Live Progress Bars 1 related to Going Asynchronous with Await Task

AutoClear and Finishing Up

Tim notices that by default Spectre.Console leaves the completed tasks on screen at 100%. If you want them to disappear automatically, call .AutoClear(true) after you set up your progress (5:42). Once the work finishes, the bars vanish instantly (6:02).

Spectre Console Live Progress Bars 2 related to AutoClear and Finishing Up

This is useful when you only need to show a progress report temporarily and don’t want to clutter the console output. Combined with interactive prompts, new panel displays, or even a var table from Spectre.Console, you can create a dynamic dashboard-style console UI.

Beyond the Basics – Different Styles and Columns

In the closing minutes Tim mentions (6:11) that there’s a lot more to explore. You can change format, colors, layouts, and use different column types. For example, you could add a new BarChart, a new Table, or combine a new Panel with progress bars to show grouped results.

The Spectre.Console documentation shows how to mix in new ProgressColumn implementations, or adjust the max value of each task, or even fold multiple tasks into a single bar for space savings (“folding space”). You could use these to display counts, total numbers, filenames, usernames, or passwords being processed—all formatted nicely inside your console application.

Conclusion

Tim, by the end of his video covered:

  • A Spectre Console progress bar built from scratch

  • How to define and update multiple progress tasks

  • How to run it synchronously with Thread.Sleep or asynchronously with await Task.Delay

  • How to use .AutoClear(true) to clear finished bars

  • Where to go for more advanced styling and documentation

This small demo shows how easily you can bring professional-looking progress bars into any C# console program. Using just Spectre.Console’s NuGet package and a few lines of code, you can display status, show percentages, and give your users a much clearer view of what your app is doing.

Hero Worlddot related to Live Progress Bars - Spectre Console Series
Hero Affiliate related to Live Progress Bars - Spectre Console Series

Earn More by Sharing What You Love

Do you create content for developers working with .NET, C#, Java, Python, or Node.js? Turn your expertise into extra income!