Free and open-source library with a simple progress indicator for .NET console projects.
Support for .NET Framework (4.5+), .NET Core and .NET.
Download from NuGet.
using SimpleConsoleProgress;
The progress bar is updated in one line. Use it if the progress is the only output in the process.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total);
}
Console.WriteLine("Process completed.");
Each progress update is written on a new line.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.WriteLine(i, total);
}
Console.WriteLine("Process completed.");
Shows just the progress value.
var total = 20;
for (int i = 0; i < total; i++)
{
Progress.Write(i, total);
}
Console.WriteLine("Process completed.");
You can provide a TimeSpan
object with the time to show next to the progress bar. SimpleConsoleProgress does not include any timers, to be as simple as possible.
var total = 20;
var timer = new Stopwatch();
timer.Start();
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, timer.Elapsed);
}
Console.WriteLine("Process completed.");
By default, '#' is used as a progress indicator. You can change it with any character you want.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, character: '>');
}
Console.WriteLine("Process completed.");
By default, single-line progress bar persists in the output. You can hide it when it completes.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, autoHide: true);
}
Console.WriteLine("Process completed.");
Use one of four different bar sizes. By default the progress bar size is set to Full - the full width of the console window.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, size: BarSize.Small);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, size: BarSize.Medium);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, size: BarSize.Big);
}
Console.WriteLine("Process completed.");
The current percentage is displayed by default in the middle of the progress bar. It can be on the left / right side of the progress bar or it can be hidden.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, location: PercentLocation.Left);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, location: PercentLocation.Right);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, location: PercentLocation.None);
}
Console.WriteLine("Process completed.");
By default, integer values are displayed. You can increase the accuracy to three decimal places.
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, accuracy: 1);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, accuracy: 2);
}
Console.WriteLine("Process completed.");
var total = 20;
for (int i = 0; i < total; i++)
{
ProgressBar.Write(i, total, accuracy: 3);
}
Console.WriteLine("Process completed.");