示例#1
0
		internal bool TrySetException (AggregateException aggregate)
		{
			if (IsCompleted)
				return false;
			
			if (!executing.TryRelaxedSet ()) {
				var sw = new SpinWait ();
				while (!IsCompleted)
					sw.SpinOnce ();

				return false;
			}
			
			HandleGenericException (aggregate);
			return true;
		}
        public bool TrySetException(IEnumerable <Exception> exceptions)
        {
            if (exceptions == null)
            {
                throw new ArgumentNullException("exceptions");
            }

            var aggregate = new AggregateException(exceptions);

            if (aggregate.InnerExceptions.Count == 0)
            {
                throw new ArgumentNullException("exceptions");
            }

            return(source.TrySetException(aggregate, false, false));
        }
示例#3
0
        public bool TrySetException(IEnumerable <Exception> exceptions)
        {
            if (exceptions == null)
            {
                throw new ArgumentNullException("exceptions");
            }

            var aggregate = new AggregateException(exceptions);

            if (aggregate.InnerExceptions.Count == 0)
            {
                throw new ArgumentNullException("exceptions");
            }

            return(ApplyOperation(setExceptionAction, aggregate));
        }
示例#4
0
        public static Task WhenAll(params Task[] tasks)
        {
            if (tasks == null)
            {
                throw new ArgumentNullException(nameof(tasks));
            }
            if (tasks.Length == 0)
            {
                return(CompletedTask);
            }

            var tcs        = new TaskCompletionSource <object>();
            var exceptions = new AggregateException[tasks.Length];
            int count      = 0;

            for (int j = 0; j < tasks.Length; j++)
            {
                var index = j;
                var t     = tasks[index];

                if (t.IsCompleted)
                {
                    if (t.IsFaulted)
                    {
                        lock (exceptions)
                            exceptions[index] = t.Exception;
                    }

                    CheckWhenAllCompletetion(tasks, tcs, null, exceptions, ref count);
                }
                else
                {
                    t.OnCompleted(() =>
                    {
                        if (t.IsFaulted)
                        {
                            lock (exceptions)
                                exceptions[index] = t.Exception;
                        }

                        CheckWhenAllCompletetion(tasks, tcs, null, exceptions, ref count);
                    });
                }
            }

            return(tcs.Task);
        }
示例#5
0
		internal void ChildCompleted (AggregateException childEx)
		{
			if (childEx != null) {
				if (ExceptionSlot.ChildExceptions == null)
					AotInterlocked.CompareExchange (ref ExceptionSlot.ChildExceptions, new ConcurrentQueue<AggregateException> (), null);
				ExceptionSlot.ChildExceptions.Enqueue (childEx);
			}

			if (childTasks.Signal () && status == TaskStatus.WaitingForChildrenToComplete) {
				ProcessChildExceptions ();
				Status = exSlot == null ? TaskStatus.RanToCompletion : TaskStatus.Faulted;
				ProcessCompleteDelegates ();
				if (parent != null &&
#if NET_4_5
				    !HasFlag (parent.CreationOptions, TaskCreationOptions.DenyChildAttach) &&
#endif
					HasFlag (creationOptions, TaskCreationOptions.AttachedToParent))
					parent.ChildCompleted (this.Exception);
			}
		}
            // Token: 0x06006EE8 RID: 28392 RVA: 0x0017DD00 File Offset: 0x0017BF00
            private bool TryExecuteTaskInlineOnTargetScheduler(Task task)
            {
                Task <bool> task2 = new Task <bool>(ConcurrentExclusiveSchedulerPair.ConcurrentExclusiveTaskScheduler.s_tryExecuteTaskShim, Tuple.Create <ConcurrentExclusiveSchedulerPair.ConcurrentExclusiveTaskScheduler, Task>(this, task));
                bool        result;

                try
                {
                    task2.RunSynchronously(this.m_pair.m_underlyingTaskScheduler);
                    result = task2.Result;
                }
                catch
                {
                    AggregateException exception = task2.Exception;
                    throw;
                }
                finally
                {
                    task2.Dispose();
                }
                return(result);
            }
 public UnobservedTaskExceptionEventArgs(AggregateException exception)
 {
     this.m_exception = exception;
 }
示例#8
0
 /// <summary>Initializes a new instance of the <see cref="T:System.Threading.Tasks.UnobservedTaskExceptionEventArgs" /> class with the unobserved exception.</summary><param name="exception">The Exception that has gone unobserved.</param>
 public UnobservedTaskExceptionEventArgs(AggregateException exception)
 {
     throw new NotImplementedException();
 }
示例#9
0
 public bool TrySetException(AggregateException exception)
 {
     return(this.Task.TrySetException(exception));
 }
示例#10
0
        internal static UnobservedTaskExceptionEventArgs FireUnobservedEvent(Task task, AggregateException e)
        {
            UnobservedTaskExceptionEventArgs args = new UnobservedTaskExceptionEventArgs(e);

            EventHandler <UnobservedTaskExceptionEventArgs> temp = UnobservedTaskException;

            if (temp == null)
            {
                return(args);
            }

            temp(task, args);

            return(args);
        }
示例#11
0
 static void SetExceptionAction(Task <TResult> source, AggregateException aggregate)
 {
     source.HandleGenericException(aggregate);
 }