Exemplo n.º 1
0
        protected virtual void CancelCompletionSourceIfNecessary()
        {
            var task = CompletionSource?.Task;

            if (task == null || task.IsFaulted || task.IsCompleted || task.IsCanceled)
            {
                return;
            }

            CompletionSource.SetCanceled();
        }
Exemplo n.º 2
0
 /// <summary>
 /// Marks the <see cref="Task{TResult}"/> that invocations will receive as canceled.
 /// </summary>
 public void SetCanceled() => CompletionSource.SetCanceled();