Mpdreamz / shellprogressbar

ShellProgressBar - display progress in your console application

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[Feature] Spawn child progress as indeterminate progress bar

diegosps opened this issue · comments

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();
		}
	}