Mpdreamz / shellprogressbar

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

Multiple bars broke view in parallel #86

Closed krikz closed 3 years ago

krikz commented 3 years ago

I'm trying display some information about tests in parallel, but look like component have some issue image image var testResultsChannel = Channel.CreateUnbounded<(bool passed, string status, string error)>(); var optionsPass = new ProgressBarOptions { DenseProgressBar = true, ForegroundColor = ConsoleColor.Blue, ForegroundColorDone = ConsoleColor.DarkGreen, BackgroundColor = ConsoleColor.DarkGray, BackgroundCharacter = '\u2593', CollapseWhenFinished = false }; var optionsErr = new ProgressBarOptions { DenseProgressBar = true, ForegroundColor = ConsoleColor.Red, ForegroundColorDone = ConsoleColor.DarkRed, BackgroundColor = ConsoleColor.DarkGray, BackgroundCharacter = '\u2593', CollapseWhenFinished = false }; using (var pbar = new ProgressBar(UserCount, "Progress", optionsPass)) { ChildProgressBar pass = null; var status = new Dictionary<string, ChildProgressBar>(); while (true) { var tcResult = await testResultsChannel.Reader.ReadAsync().ConfigureAwait(false); if (tcResult.passed) { if (pass == null) { pass = pbar.Spawn(UserCount, "PASS", optionsPass); } pass.Tick(); pbar.Tick(); } else if (!string.IsNullOrEmpty(tcResult.error)) { if (!status.ContainsKey(tcResult.error)) { status.Add(tcResult.error, pbar.Spawn(UserCount, tcResult.error, optionsErr)); } status[tcResult.error].Tick(); pbar.Tick(); } else if (!string.IsNullOrEmpty(tcResult.status)) { if (!status.ContainsKey(tcResult.status)) { status.Add(tcResult.status, pbar.Spawn(UserCount, tcResult.status, optionsPass)); } status[tcResult.status].Tick(); } } }

krikz commented 3 years ago

This my mistake