public bool TrySetCanceled(OperationCanceledException exception) {
			if (Interlocked.CompareExchange(ref state, Canceled, Pending) == Pending) {
				this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception));
				TryInvokeContinuation();
				return true;
			}

			return false;
		}
Exemple #2
0
 public bool TrySetException(Exception exception)
 {
     if (Interlocked.CompareExchange(ref state, Faulted, Pending) == Pending)
     {
         this.exception = new ExceptionHolder(ExceptionDispatchInfo.Capture(exception));
         TryInvokeContinuation();
         return(true);
     }
     return(false);
 }