Пример #1
0
        private void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var message = nameof(UnobservedTaskExceptionHandler);

            e?.SetObserved(); // Prevents the Program from terminating.

            if (e.Exception != null && e.Exception is Exception tuex)
            {
                message = string.Format(CultureInfo.InvariantCulture, "{0} Exception: {1}", message, tuex.Message);
                Log.Error(tuex, message);
            }
            else if (sender is Exception ex)
            {
                message = string.Format(CultureInfo.InvariantCulture, "{0} Exception: {1}", message, ex.Message);
                Log.Error(ex, message);
            }
        }
Пример #2
0
        private static async void HandleUnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var message = DefaultErrorMessage;

            e?.SetObserved(); // Stops the process from terminating.

            if (e.Exception is Exception tuex)
            {
                message = $"Congratulations, you have broken this program like no other user before you!\n\nException : {tuex.Message}\n\nStack : {tuex.StackTrace}";
            }
            else if (sender is Exception ex)
            {
                message = $"Congratulations, you have broken this program like no other user before you!\n\nException : {ex.Message}\n\nStack : {ex.StackTrace}";
            }

            await Console.Out.WriteAsync(message).ConfigureAwait(false);
        }
Пример #3
0
        /// <summary>
        /// バックグラウンドタスクで発生した未処理例外を処理
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            //taskcanceledは握りつぶす
            if (e.Exception?.InnerException is TaskCanceledException)
            {
                return;
            }
            var logger    = DIFactory.Provider.GetRequiredService <ILogger>();
            var exception = e?.Exception?.InnerException as Exception;

            if (exception is not null)
            {
                logger.Error("バックグラウンドタスクの実行中にエラーが発生しました。", exception);
            }
            if (this.ConfirmUnhandledException(exception, "バックグラウンドタスク"))
            {
                e?.SetObserved();
            }
            else
            {
                Environment.Exit(1);
            }
        }
Пример #4
0
 void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     HandleException(e.Exception);
     e.SetObserved();
 }
Пример #5
0
 static void TaskScheduler_TaskUnobservedException_Handler(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved(); //observe/ignore this exception
 }
Пример #6
0
 void DotNet40_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     // On .NET 4.0, an unobserved exception in a task terminates the process unless we mark it as observed
     e.SetObserved();
 }
 private void unobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
 {
     output.WriteLine(e.Exception.InnerException.Message);
     // if not set exception is thrown from the tasks management context
     e.SetObserved();
 }
Пример #8
0
 void DotNet40_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     // On .NET 4.0, an unobserved exception in a task terminates the process unless we mark it as observed
     e.SetObserved();
 }
Пример #9
0
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     SampleAnimations.App.OnUnhandledException(e.Exception);
 }
Пример #10
0
 void OnUnobservedTaskException(object?sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     Handle(e.Exception);
 }
Пример #11
0
 private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     s_tracer.TraceEvent(TraceEventType.Error, 0, e.Exception.Flatten().InnerException.ToString());
     e.SetObserved();
 }
Пример #12
0
 /// <summary>
 /// Observe unhandled exceptions
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     CurrentDomainUnhandledException(sender, new UnhandledExceptionEventArgs(e.Exception, false));
 }
Пример #13
0
 private static void UnhandledTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Log.FatalException("An error occurred that caused the server task to terminate.", e.Exception);
     e.SetObserved();
 }
Пример #14
0
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     ExitSystemError(e.Exception);
     e.SetObserved();
 }
Пример #15
0
 static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     FlurryWP8SDK.Api.LogError("Async Error", e.Exception);
 }
Пример #16
0
 private void UnobservedHandler(object sender, UnobservedTaskExceptionEventArgs args)
 {
     logger.LogError(args.Exception.Message);
     args.SetObserved();
 }
Пример #17
0
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
 }
Пример #18
0
 private void OnTaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     HandleException(e.Exception);
 }
Пример #19
0
 static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Console.WriteLine("Unobserved exception!");
     Console.WriteLine(e.Exception);
     e.SetObserved();
 }
Пример #20
0
 private void OnTaskSchedulerException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     RaiseLog(new LogMessage(this, TimeHelper.NowWithOffset, LogLevels.Error, () => e.Exception.ToString()));
     e.SetObserved();
 }
Пример #21
0
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     Logger.Write(e.Exception.Message);
     HockeyClient.Current.TrackException(e.Exception);
 }
Пример #22
0
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs args)
 {
     args.SetObserved();
     TrackError(args.Exception, nameof(TaskScheduler_UnobservedTaskException));
 }
Пример #23
0
 void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     ProcessError(e.Exception);
     ProcessError();
     e.SetObserved();
 }
Пример #24
0
 // Example 4
 void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     MessageBox.Show("4. TaskScheduler_UnobservedTaskException");
     log.ProcessError(e.Exception);
     e.SetObserved();
 }
Пример #25
0
 private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     // Prevents the process from crashing
     e.SetObserved();
     Log.Error(e.Exception, "UnobservedTaskException");
 }
Пример #26
0
 private void onUnobservedTaskException(object?sender, UnobservedTaskExceptionEventArgs args)
 {
     args.SetObserved();
     OnException((Exception)args.Exception);
 }
Пример #27
0
 void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     //task线程内未处理捕获
     MessageBox.Show("捕获线程内未处理异常:" + e.Exception.Message);
     e.SetObserved();//设置该异常已察觉(这样处理后就不会引起程序崩溃)
 }
Пример #28
0
 private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
 {
     ExceptionHandler.LogException(unobservedTaskExceptionEventArgs.Exception);
     unobservedTaskExceptionEventArgs.SetObserved();
 }
Пример #29
0
        private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            Debug.WriteLine($"Unhandled task exception: {e.Exception.InnerExceptions.Aggregate("", (a, b) => $"{a}\n{b}")}");

            e.SetObserved();
        }
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     _dispatcher.BeginInvoke(new Action(() => ShowMessageBox(e.Exception)));
 }
Пример #31
0
 /// <summary>
 /// We fire off tasks but only process the first one that returns, and don't bother to
 /// cancel the others --- in which case if they throw an exception, that exception could
 /// be thrown when the task object is garbage-collected.  We avoid that via this handler.
 ///
 /// NOTE: this is registered in the class's static constructor, so only registered once.
 /// </summary>
 private static void TaskUnobservedException_Handler(object sender, UnobservedTaskExceptionEventArgs e)
 {
     /* ignore since first result was already processed */
     e.SetObserved();
 }