Esempio n. 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));
        }
Esempio n. 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));
        }
Esempio n. 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);
        }
Esempio n. 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;
 }
Esempio n. 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();
 }
Esempio n. 9
0
 public bool TrySetException(AggregateException exception)
 {
     return(this.Task.TrySetException(exception));
 }
Esempio n. 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);
        }
Esempio n. 11
0
 static void SetExceptionAction(Task <TResult> source, AggregateException aggregate)
 {
     source.HandleGenericException(aggregate);
 }