/// <summary>
 /// Transitions the underlying Task<TResult> into the Faulted state and binds it to a specified exception.
 /// </summary>
 /// <param name="p_exception"></param>
 public void SetException(System.Threading.Tasks.AggregateException p_exception)
 {
     if (!this.TrySetException(p_exception))
     {
         throw new InvalidOperationException("Cannot set the exception of a completed task.");
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// try to set specified exception
 /// </summary>
 /// <param name="p_result"></param>
 /// <returns></returns>
 internal bool TrySetException(System.Threading.Tasks.AggregateException p_exception)
 {
     if (m_isCompleted)
     {
         return(false);
     }
     m_isCompleted    = true;
     this.m_exception = p_exception;
     RunContinuations();
     return(true);
 }
        /// <summary>
        /// Attempts to transition the underlying Task<TResult> into the Faulted state and binds it to a specified exception.
        /// </summary>
        /// <param name="exception"></param>
        /// <returns></returns>
        public bool TrySetException(Exception exception)
        {
            System.Threading.Tasks.AggregateException exception2 = exception as System.Threading.Tasks.AggregateException;
            if (exception2 != null)
            {
                return(this.Task.TrySetException(exception2));
            }
            UnityTask <T> task = this.Task;

            Exception[] innerExceptions = new Exception[] { exception };
            return(task.TrySetException(new System.Threading.Tasks.AggregateException(innerExceptions).Flatten()));
        }
 /// <summary>
 /// Attempts to transition the underlying Task<TResult> into the Faulted state and binds it to a specified exception.
 /// </summary>
 /// <param name="exception"></param>
 /// <returns></returns>
 public bool TrySetException(System.Threading.Tasks.AggregateException exception)
 {
     return(this.Task.TrySetException(exception));
 }