Mpdreamz / shellprogressbar

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

[Feature] Spawn child progress as indeterminate progress bar #99

Closed diegosps closed 2 years ago

diegosps commented 2 years ago

I have this use case where a process with multiple steps is displayed using the nested progress bar. However some of these steps are not deterministic. Currently, there is no way to use the IndeterminateProgressBar as a child progress.

I made a simple PR #98 that enables the adds the SpawnIndeterminate function in ProgressBarBase Example:


using (var pbar = new ProgressBar(totalChildren, "main progressbar", options))
    {
        for (int i = 1; i <= totalChildren; i++)
        {
            pbar.Message = $"Start {i} of {totalChildren}: main progressbar";
            using (var child = pbar.SpawnIndeterminate("child action " + i, childOptions))
            {
                Thread.Sleep(1000 * random.Next(5, 15));
                child.Finished();
            }
            pbar.Tick();
        }
    }