Mpdreamz / shellprogressbar

ShellProgressBar - display progress in your console application
MIT License
1.44k stars 134 forks source link

Output not updating until function end #88

Closed AntMooreWebDev closed 3 years ago

AntMooreWebDev commented 3 years ago

I'm getting an issue where the console interface is not being updated until the function ends, or I call Thread.Sleep()

const int totalTicks = 10;
var options = new ProgressBarOptions
{
    ProgressCharacter = '─',
    ProgressBarOnBottom = true,
};
using (var pbar = new ProgressBar(totalTicks, "Initial message", options))
{
    pbar.Tick(); //will advance pbar to 1 out of 10.
                    //we can also advance and update the progressbar text
    pbar.Tick("Step 2 of 10");
    pbar.Tick("Step 3 of 10");
    Thread.Sleep(1000);
    pbar.Tick("Step 4 of 10");
    pbar.Tick("Step 5 of 10");
    Thread.Sleep(1000);
    pbar.Tick("Step 6 of 10");
    pbar.Tick("Step 7 of 10");
    pbar.Tick("Step 8 of 10");
    Thread.Sleep(1000);
    pbar.Tick("Step 9 of 10");
    pbar.Tick("Step 10 of 10");
}

When running the application with, or without breakpoints, the interface is only updated after Thread.Sleep(), or once the function returns..