-
Notifications
You must be signed in to change notification settings - Fork 137
/
Copy pathIndeterminateChildrenNoCollapse.cs
41 lines (40 loc) · 1.07 KB
/
IndeterminateChildrenNoCollapse.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System;
using System.Threading;
using System.Threading.Tasks;
namespace ShellProgressBar.Example.Examples
{
public class IndeterminateChildrenNoCollapseExample : ExampleBase
{
protected override async Task StartAsync()
{
const int totalChildren = 2;
Random random = new Random();
var options = new ProgressBarOptions
{
ForegroundColor = ConsoleColor.Yellow,
BackgroundColor = ConsoleColor.DarkGray,
ProgressCharacter = '─'
};
var childOptions = new ProgressBarOptions
{
ForegroundColor = ConsoleColor.Green,
BackgroundColor = ConsoleColor.DarkGray,
ProgressCharacter = '─',
CollapseWhenFinished = false
};
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))
{
await Task.Delay(1000 * random.Next(5, 15));
child.Finished();
}
pbar.Tick();
}
}
}
}
}