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;
		}
Пример #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);
 }