public void DrainDueToFailure(AmqpError error) { for (int i = 0; i < _tasks.Length; i++) { var tcs = Interlocked.Exchange(ref _tasks[i], null); if (tcs == null) continue; tcs.SetException(new Exception("Cancelled due to error " + error.ToErrorString()), runContinuationAsync: true); } }
public void DrainDueToFailure(AmqpError error) { Exception exception = null; for (int i = 0; i < _tasks.Length; i++) { var tcs = Interlocked.Exchange(ref _tasks[i], null); if (tcs == null) { continue; } if (exception == null) { exception = new Exception("Cancelled due to error " + error.ToErrorString()); } tcs.TrySetException(exception); } }