Ejemplo n.º 1
0
        public void SetException(Exception exception)
        {
            if (exception == null)
            {
                throw new ArgumentNullException("exception");
            }
            System.Threading.Tasks.Task <TResult> task = this.m_task ?? this.Task;
            OperationCanceledException            canceledException = exception as OperationCanceledException;

            if ((canceledException != null ? (task.TrySetCanceled(canceledException.CancellationToken, (object)canceledException) ? 1 : 0) : (task.TrySetException((object)exception) ? 1 : 0)) == 0)
            {
                throw new InvalidOperationException(Environment.GetResourceString("TaskT_TransitionToFinal_AlreadyCompleted"));
            }
        }