in src/PowerShell/Utilities/ConcurrencyTaskScheduler.cs [195:236]
private async void RunConcurrentTaskAsync(long taskId, Task task)
{
Interlocked.Increment(ref activeTaskCount);
try
{
taskStatus.TryAdd(taskId, false);
await task.ConfigureAwait(false);
Interlocked.Increment(ref finishedTaskCount);
}
catch (Exception ex)
{
Interlocked.Increment(ref failedTaskCount);
if (OnError != null)
{
TaskExceptionEventArgs eventArgs = new TaskExceptionEventArgs(ex);
try
{
OnError(this, eventArgs);
}
catch (Exception devException)
{
Debug.Fail(devException.Message);
}
}
}
finally
{
taskStatus.TryUpdate(taskId, true, false);
}
Interlocked.Decrement(ref activeTaskCount);
if (!disposed)
{
taskCounter?.Signal();
RunRemainingTask();
}
}