private static async Task MainAsync(string[] args) { // Some biolerplate to react to close window event, CTRL-C, kill, etc _handler += Handler; SetConsoleCtrlHandler(_handler, true); var options = new ProgressBarOptions { ProgressCharacter = '─', ProgressBarOnBottom = true }; #if PARALLEL var tasks = new List <Task>(); var terms = Results.GetNotNullTerms(Terms, out int count); //using (var progressBar = new ProgressBar(count, $"Step 0 of {count}: ", options)) { for (int i = 0; i < MAX_INSTANCES; i++) { var i1 = i; tasks.Add(new Task(async() => { using (var web = DriverHelper.CreateDriver(i1)) { await GenerateResults(web, null, terms, GetMin(i1, count), GetMax(i1, count), i1 == 0); webs.Add(web); } })); } Parallel.ForEach(tasks, task => task.Start()); await Task.WhenAll(tasks); } #else var terms = Results.GetNotNullTerms(Terms, out var count); using (var progressBar = new ProgressBar(count, $"Step 0 of {count}: ", options)) // ReSharper disable once ConvertToUsingDeclaration using (var web = DriverHelper.CreateDriver()) { await GenerateResults(web, progressBar, terms, 0, count, true); } #endif SortResults(ResultSorting); DisplayResults(ResultFormat); //Console.Read(); }