Mpdreamz / shellprogressbar

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

Only two levels displayed if ProgressBarOnBottom = true #71

Closed GeneratedNickname closed 3 years ago

GeneratedNickname commented 3 years ago

Example code:

                var progressBarOptions = new ProgressBarOptions
                {
                    CollapseWhenFinished = true,
                    ProgressBarOnBottom = true,
                    DisplayTimeInRealTime = true,
                    ForegroundColor = ConsoleColor.White
                };

                using (var l1Bar =
                    new ProgressBar(10, "Level 1", progressBarOptions))
                {
                    for (int i = 0; i < 10; i++)
                    {
                        using (var l2Bar =
                            l1Bar.Spawn(10, $"Level 2 [{i}]", progressBarOptions))
                        {
                            for (int j = 0; j < 10; j++)
                            {
                                using (var l3Bar =
                                    l2Bar.Spawn(10, $"Level 3 [{j}]", progressBarOptions))
                                {
                                    for (int k = 0; k < 10; k++)
                                    {
                                        Thread.Sleep(200);
                                        l3Bar.Tick();
                                    }
                                }
                                l2Bar.Tick($"Level 2 [{i}]");
                            }
                        }
                        l1Bar.Tick();
                    }
                }

When ProgressBarOnBottom is set to true only two bars appear. When the option is commented out, all three will appear.

Bozhidar-A commented 3 years ago

After some debugging I think I found the issue, fixed it and made a pull request here #75