コード例 #1
0
        public static Task Catch(this Task parent, Action <AggregateException> action)
        {
            var stackTrace = new StackTrace();

            return(parent.ContinueWith(task =>
            {
                if (task.IsFaulted == false)
                {
                    return;
                }

                var ex = task.Exception.ExtractSingleInnerException();
                Execute.OnTheUI(() => ErrorPresenter.Show(ex, stackTrace))
                .ContinueWith(_ => action(task.Exception));
            }));
        }
コード例 #2
0
ファイル: InvocationExtensions.cs プロジェクト: larsw/ravendb
        public static Task <TResult> Catch <TResult>(this Task <TResult> parent, Action <AggregateException> action)
        {
            var stackTrace = new StackTrace();

            return(parent.ContinueWith(task =>
            {
                if (task.IsFaulted == false)
                {
                    return task;
                }

                var ex = task.Exception.ExtractSingleInnerException();
                if (ErrorHandler.Handle(ex) == false)
                {
                    Execute.OnTheUI(() => ErrorPresenter.Show(ex, stackTrace))
                    .ContinueWith(_ => action(task.Exception));
                }
                return task;
            }).Unwrap());
        }