private void OnUnobservedTaskException(object sender, _THREADING.UnobservedTaskExceptionEventArgs e)
        {
            // prevent exception escalation
            e.SetObserved( );

            _logger.LogError(String.Format("task Exception: '{0}'\r\nTrace:\r\n{1}", e.Exception.Message, e.Exception.StackTrace));
        }
Esempio n. 2
0
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     //var client = new Microsoft.ApplicationInsights.TelemetryClient();
     //client.TrackException(e.Exception);
     _logger.Error(e.Exception);
     e.SetObserved();
 }
		protected override void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
		{
			logger.Error(e.Exception);
			e.SetObserved();

			base.OnUnobservedTaskException(sender, e);
		}
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     var exception = e.Exception;
     var baseException = e.Exception.GetBaseException();
     Logger.ErrorException("An unobserved task exception occured.", exception);
     e.SetObserved();
 }
Esempio n. 5
0
        static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.SetObserved();

            var exception = e.Exception.Flatten();

            Logger.Error(exception);
        }
        private void OnUnhandledExceptionRaised( object sender, UnobservedTaskExceptionEventArgs e )
        {
            var handler = this.ExceptionCaught;
            if( handler.NotNullReference() )
                handler(e.Exception);

            e.SetObserved();
        }
 private void TaskScheduler_UnobservedTaskException (object sender, UnobservedTaskExceptionEventArgs args)
 {
     args.Exception.Flatten();
     var excArgs = new UnhandledExceptionsEventArgs(args.Exception.InnerExceptions, UnhandledExceptionSource.TaskScheduler);
     OnUnhandledException(excArgs);
     if (excArgs.Handled)
         args.SetObserved();
 }
Esempio n. 8
0
 public static void handleUnObservedExceptions(object sender, UnobservedTaskExceptionEventArgs eventArgs)
 {
     eventArgs.SetObserved();
     ((AggregateException)eventArgs.Exception).Handle(ex =>
     {
         Console.WriteLine("Unobserved exception type: [{0}] Message[{1}] ", ex.GetType(), ex.Message);
         return true;
     });
 }
 void taskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     e.Exception.Flatten().Handle(ex =>
     {
         AppMessenger.Messenger.NotifyColleagues("ShowLog", ex.Message);
         return true;
     });
 }
Esempio n. 10
0
        private static void Tasks_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.SetObserved();

            var logger = ServiceLocator.Current.GetInstance<ILog>();

            logger.Error(
                $"An unobserved task exception occures! Sender was {(sender != null ? sender.GetType().FullName : "(not set!)")}.",
                e.Exception);
        }
 // Ensure unobserved task exceptions (unawaited async methods returning Task or Task<T>) are handled
 // Example: Call this method without 'await'
 // private async Task<string> TestStringTask()
 // {
 //    throw new Exception("TestStringTaskException");
 // }
 private void OnTaskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     if (e.Exception != null)
     {
         var isHandled = this.HandleException(e.Exception);
         if (isHandled)
         {
             e.SetObserved();
         }
     }
 }
Esempio n. 12
0
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     if (handleUnobserved)
     {
         e.SetObserved();
         Console.WriteLine("Unobserved exception logged and set to observed in TaskScheduler_UnobservedTaskException, Exception is: {0}", e.Exception);
     }
     else
         Console.WriteLine("Unobserved exception logged - process WILL BE KILLED because we are running .NET 4.0, Exception is: {0}",
             e.Exception);
 }
Esempio n. 13
0
 /// <summary>
 /// 异步处理县城异常
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void TaskScheduler_UnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e)
 {
     try
     {
         ("异步处理县城异常:《" + e.Exception.ToString() + "》").WriteToLog(log4net.Core.Level.Error);
         e.SetObserved();
     }
     catch (Exception ex)
     {
         ("不可恢复的异步处理县城异常:《" + ex.ToString() + "》").WriteToLog(log4net.Core.Level.Error);
     }
 }
Esempio n. 14
0
 private void TaskSchedulerOnUnobservedTaskException(object sender,
                                                     UnobservedTaskExceptionEventArgs
                                                         unobservedTaskExceptionEventArgs)
 {
     if (Debugger.IsAttached)
         Debug.WriteLine(unobservedTaskExceptionEventArgs.Exception.Message);
     else
     {
         MessageBox.Show(unobservedTaskExceptionEventArgs.Exception.Message);
     }
     unobservedTaskExceptionEventArgs.SetObserved();
 }
Esempio n. 15
0
        private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            if (!e.Observed)
            {
                e.SetObserved();

                Error error;
                lock (_syncRoot)
                {
                    error = new Error(e.Exception)
                    {
                        HostName = _prototype.HostName,
                        User = _prototype.User,
                    };
                    error.ServerVariables.Add(_prototype.ServerVariables);
                    error.QueryString.Add(_prototype.QueryString);
                    error.Cookies.Add(_prototype.Cookies);
                    error.Form.Add(_prototype.Form);
                }
                ErrorLog.GetDefault(null).Log(error);
            }
        }
Esempio n. 16
0
 static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Interlocked.Exchange(ref _exception, e.Exception);
     e.SetObserved();
 }
Esempio n. 17
0
 /// <summary>
 /// Invoked when the task schedule sees an exception occur
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e">Details about the task exception.</param>
 private void TaskScheduler_UnobservedTaskException(object sender, System.Threading.Tasks.UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     Platform.Current.AppUnhandledException(e.Exception);
 }
 private void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     this.NotifyError(e.Exception);
 }
Esempio n. 19
0
        void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.SetObserved();

            ShowUnhandledExceptionDialog(e.Exception);
        }
Esempio n. 20
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 TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.SetObserved();

            // Calling flatten to get rid of any inner aggregate exceptions.  Handle will iterate through all inner exceptions
            //	(each iteration must return true, or those falses will rethrow, and bring down the process)
            e.Exception.Flatten().Handle(ex =>
            {
                try
                {
                    //TODO: Log ex


                    //	Tell the exception not to worry
                    return true;
                }
                catch (Exception)
                {
                    //	Logging failed, but it doesn't matter.  Don't let this bomb the process
                    return true;
                }
            });
        }
Esempio n. 22
0
 private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Console.WriteLine(e.Exception.GetBaseException());
     e.SetObserved();
 }
Esempio n. 23
0
        /// <summary>
        /// Event handler to handle unobserved task exception.
        /// </summary>
        /// <param name="sender">The one who raises the event</param>
        /// <param name="e">Arguments supplied with the event</param>
        private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.Exception.ThrowOnDispatcher();

            e.SetObserved();
        }
		private void OnTaskSchedulerException(object sender, UnobservedTaskExceptionEventArgs e)
		{
			RaiseLog(new LogMessage(this, TimeHelper.NowWithOffset, LogLevels.Error, () => e.Exception.ToString()));
			e.SetObserved();
		}
Esempio n. 25
0
		/// <summary>
		/// Used for handling System.Threading.Tasks bound to a background worker thread.
		/// Handles the <see cref="UnobservedTaskException"/> event in <see cref="System.Threading.Tasks"/> namespace.
		/// </summary>
		/// <param name="sender">Exception sender object.</param>
		/// <param name="e">Real exception is in: e.Exception.</param>
		private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
		{
			if (Settings.HandleExceptions)
			{
				Logger.Trace("Starting to handle a System.Threading.Tasks.UnobservedTaskException.");
				var executionFlow = new BugReport().Report(e.Exception, ExceptionThread.Task);
				if (executionFlow == ExecutionFlow.BreakExecution)
				{
					e.SetObserved();
					Environment.Exit(0);
				}
				else if (executionFlow == ExecutionFlow.ContinueExecution)
				{
					e.SetObserved();
				} 
			}
		}
Esempio n. 26
0
 void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     MeCore.Invoke(new Action(()=> {
         var crash = new ErrorReport(e.Exception);
         crash.Show();
     }));
 }
 private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Debug.WriteLine(e.Exception.GetBaseException().ToString());
     e.SetObserved();
 }
Esempio n. 28
0
 private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
     HandleException(e.Exception);
 }
Esempio n. 29
0
 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e) {
     //防止因线程取消等错误把程挂掉
     e.SetObserved();
 }
Esempio n. 30
0
		static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
		{
			HandleException(e.Exception, false);
			e.SetObserved();
		}
Esempio n. 31
0
 private void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
 {
     Trace.TraceError(unobservedTaskExceptionEventArgs.Exception.Message);
     unobservedTaskExceptionEventArgs.SetObserved();
 }
Esempio n. 32
0
 static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     e.SetObserved();
 }
Esempio n. 33
0
 private static void TaskSchedulerOnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs eventArgs)
 {
    Error(eventArgs.Exception);
    eventArgs.SetObserved();
 }