Beispiel #1
0
        internal static void WaitAndUnaggregateException(this Task task, IEnumerable <BatchClientBehavior> rootBehaviors, IEnumerable <BatchClientBehavior> additionalBehaviors)
        {
            BehaviorManager bhMgr = new BehaviorManager(rootBehaviors, additionalBehaviors);
            SynchronousMethodExceptionBehavior exceptionBehavior = bhMgr.GetBehaviors <SynchronousMethodExceptionBehavior>().LastOrDefault();

            if (exceptionBehavior != null)
            {
                exceptionBehavior.Wait(task);
            }
            else
            {
                task.WaitAndUnaggregateException();
            }
        }
Beispiel #2
0
        internal static T WaitAndUnaggregateException <T>(this Task <T> task, IEnumerable <BatchClientBehavior> rootBehaviors, IEnumerable <BatchClientBehavior> additionalBehaviors)
        {
            BehaviorManager bhMgr = new BehaviorManager(rootBehaviors, additionalBehaviors);
            SynchronousMethodExceptionBehavior exceptionBehavior = bhMgr.GetBehaviors <SynchronousMethodExceptionBehavior>().LastOrDefault();
            T result;

            if (exceptionBehavior != null)
            {
                exceptionBehavior.Wait(task);
                result = task.Result;
            }
            else
            {
                result = task.WaitAndUnaggregateException();
            }

            return(result);
        }