public void SetException(Exception exception) { if (!IsCompleted) { IsCompleted = true; if (!CompletionSource.Task.IsCompleted) { CompletionSource.SetException(exception); } } }
/// <summary> /// Sets the <typeparamref name="TException"/> exception that invocations will receive. /// </summary> /// <param name="exception"></param> public void SetException <TException>(TException exception) where TException : Exception => CompletionSource.SetException(exception);