Note that an alias SysConsole was created for System.Console because the namespace of this library is LSHoude.Console. If we had not created an alias, we would have to call System.Console every time instead of SysConsole. I decided to call the namespace Console even if it has the drawback because Console was the most appropriate name.

EXAMPLE 1

Simplest example

ProgressBar pBar = new ProgressBar();
pBar.ProgressInPercentage = 50;
pBar.StatusMessage = "1 of 2";
pBar.ProgressInPercentage = 100;
pBar.StatusMessage = "2 of 2";
pBar.Dispose();

EXAMPLE 2

Create a progress bar for a progress of 1 to 999.

const int PROGRESS_TOTAL = 999;
const int SLEEP_TIME_IN_MS = 10;
SysConsole.WriteLine("This is a sample of the simple progress bar.\n");
using (ProgressBar pBar = new ProgressBar())
{
        for (int i = 1; i <= PROGRESS_TOTAL; i++)
        {
                pBar.ProgressInPercentage = (int)((double)i / (double)PROGRESS_TOTAL * 100);
                pBar.StatusMessage = string.Format("Status message ({0} of {1})", i, PROGRESS_TOTAL);
                System.Threading.Thread.Sleep(new TimeSpan(0, 0, 0, 0, SLEEP_TIME_IN_MS));
        }
}
SysConsole.WriteLine("\nPress any key to quit.");
SysConsole.ReadLine();

Last edited Jul 24, 2014 at 7:25 PM by houdelou, version 6