public async Task RunAsync(List <string> names, bool skipDependencies, bool dryRun, bool parallel, Logger log, Func <Exception, bool> messageOnly) { await log.Running(names).ConfigureAwait(false); var stopWatch = Stopwatch.StartNew(); try { if (!skipDependencies) { this.ValidateDependenciesAreAllDefined(); } this.ValidateTargetGraphIsCycleFree(); this.Validate(names); var targetsRan = new ConcurrentDictionary <string, Task>(); if (parallel) { var tasks = names.Select(name => this.RunAsync(name, names, skipDependencies, dryRun, true, targetsRan, log, messageOnly, new Stack <string>())); await Task.WhenAll(tasks).ConfigureAwait(false); } else { foreach (var name in names) { await this.RunAsync(name, names, skipDependencies, dryRun, false, targetsRan, log, messageOnly, new Stack <string>()).ConfigureAwait(false); } } } catch (Exception) { await log.Failed(names, stopWatch.Elapsed.TotalMilliseconds).ConfigureAwait(false); throw; } await log.Succeeded(names, stopWatch.Elapsed.TotalMilliseconds).ConfigureAwait(false); }