public async Task StartAsync(IProgress <ProgressEventArgs> progress, CancellationToken ct) { if (Status == DeploymentStatus.Error) { progress?.Report(new ProgressEventArgs("Error, deployment not valid")); return; } var targetsTasks = Targets .AsParallel() .Select(async(target) => await OnEachTarget(progress, target, ct) ); await Task.WhenAll(targetsTasks).ConfigureAwait(false); ct.ThrowIfCancellationRequested(); if (Targets.Where(x => x.DeploymentState != Database.DatabaseDeploymentState.Success).Count() > 0) { Status = DeploymentStatus.Error; } else { Status = DeploymentStatus.Idle; } }