当前位置: 首页>>代码示例>>C#>>正文


C# Tasks.UnobservedTaskExceptionEventArgs类代码示例

本文整理汇总了C#中System.Threading.Tasks.UnobservedTaskExceptionEventArgs的典型用法代码示例。如果您正苦于以下问题:C# UnobservedTaskExceptionEventArgs类的具体用法?C# UnobservedTaskExceptionEventArgs怎么用?C# UnobservedTaskExceptionEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


UnobservedTaskExceptionEventArgs类属于System.Threading.Tasks命名空间,在下文中一共展示了UnobservedTaskExceptionEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TaskScheduler_UnobservedTaskException

        void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            try
            {
                Exception ex = (Exception)e.Exception;
                string LogFile = Logger.LogError(ex);

                MessageBox.Show(
                    "The application encountered a fatal error and must exit. This error has been logged and should be reported using the Error Report utility.\n\n" +
                        "Error:\n" +
                        ex.Message +
                        "\n\nStack Trace:\n" +
                        ex.StackTrace,
                    "Fatal Error");

                Process proc = new Process();
                proc.EnableRaisingEvents = false;
                proc.StartInfo.FileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "ErrorReport.exe");
                proc.StartInfo.Arguments = LogFile;
                proc.Start();
            }
            finally
            {
                System.Environment.Exit(1);
            }
        }
开发者ID:Slashka-DK,项目名称:BlitzChat,代码行数:26,代码来源:App.xaml.cs

示例2: HandleTaskException

        private static void HandleTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var exception = e.Exception;

            Console.WriteLine("Task Error: {0}", exception);
            Logger.Error("Task Error: " + exception.Message, exception);
        }
开发者ID:Djohnnie,项目名称:Sonarr,代码行数:7,代码来源:GlobalExceptionHandlers.cs

示例3: OnUnobservedTaskException

		protected override void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
		{
			logger.Error(e.Exception);
			e.SetObserved();

			base.OnUnobservedTaskException(sender, e);
		}
开发者ID:matteomigliore,项目名称:HSDK,代码行数:7,代码来源:TestExceptionHandler.cs

示例4: HandleTaskSchedulerException

 static void HandleTaskSchedulerException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     var exception = e != null
         ? (e.Exception ?? new Exception ("Unhandled Task exception (null Exception)."))
         : new Exception ("Unhandled Task exception (null UnobservedTaskExceptionEventArgs).");
     HandleException (exception, fatal: false);
 }
开发者ID:patridge,项目名称:xamarin-forms-value-converters,代码行数:7,代码来源:AppDelegate.cs

示例5: AudioPlayer_UnobservedException

        void AudioPlayer_UnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            Debug.WriteLine("AudioPlayer UnobservedException {0}", e.Exception.Message);

            if (Debugger.IsAttached)
                Debugger.Break();
        }
开发者ID:henricj,项目名称:phonesm,代码行数:7,代码来源:AudioPlayer.cs

示例6: TaskScheduler_UnobservedTaskException

 private void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     //var client = new Microsoft.ApplicationInsights.TelemetryClient();
     //client.TrackException(e.Exception);
     _logger.Error(e.Exception);
     e.SetObserved();
 }
开发者ID:ChinaRAUnion,项目名称:RedAlertPlus,代码行数:7,代码来源:App.xaml.cs

示例7: TaskScheduler_UnobservedTaskException

 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();
 }
开发者ID:IngageNetworks,项目名称:IN.Chat,代码行数:7,代码来源:RegisterErrorHandling.cs

示例8: TaskSchedulerOnUnobservedTaskException

		private static void TaskSchedulerOnUnobservedTaskException(object sender,
			UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
		{
			var newExc = new Exception("TaskSchedulerOnUnobservedTaskException",
				unobservedTaskExceptionEventArgs.Exception);
			LogUnhandledException(newExc);
		}  
开发者ID:P3PPP,项目名称:XFAedSearch,代码行数:7,代码来源:MainActivity.cs

示例9: InternalUnobservedTaskExceptionHandler

        private static void InternalUnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs e)
        {
            var aggrException = e.Exception;
            var baseException = aggrException.GetBaseException();
            var tplTask = (Task)sender;
            var contextObj = tplTask.AsyncState;
            var context = contextObj as ISchedulingContext;

            try
            {
                if (unobservedExceptionHandler != null)
                {
                    unobservedExceptionHandler(context, baseException);
                }
            }
            finally
            {
                if (e.Observed)
                {
                    logger.Info(ErrorCode.Runtime_Error_100311, "UnobservedExceptionsHandlerClass caught an UnobservedTaskException which was successfully observed and recovered from. BaseException = {0}. Exception = {1}",
                            baseException.Message, LogFormatter.PrintException(aggrException));
                }
                else
                {
                    var errorStr = String.Format("UnobservedExceptionsHandlerClass Caught an UnobservedTaskException event sent by {0}. Exception = {1}",
                            OrleansTaskExtentions.ToString((Task)sender), LogFormatter.PrintException(aggrException));
                    logger.Error(ErrorCode.Runtime_Error_100005, errorStr);
                    logger.Error(ErrorCode.Runtime_Error_100006, "Exception remained UnObserved!!! The subsequent behavior depends on the ThrowUnobservedTaskExceptions setting in app config and .NET version.");
                }
            }
        }
开发者ID:Rejendo,项目名称:orleans,代码行数:31,代码来源:UnobservedExceptionsHandlerClass.cs

示例10: OnUnobservedTaskException

 private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     Tracer.Get(typeof(Program)).Error(e.Exception.Flatten(), "Unexpected exception");
     Console.WriteLine(e.Exception.Flatten().ToString());
     Console.WriteLine("Press [Enter] to exit.");
     Console.ReadLine();
     Process.GetCurrentProcess().Kill();
 }
开发者ID:kzu,项目名称:OctoFlow,代码行数:8,代码来源:Program.cs

示例11: TaskScheduler_UnobservedTaskException

        static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
        {
            e.SetObserved();

            var exception = e.Exception.Flatten();

            Logger.Error(exception);
        }
开发者ID:ganesum,项目名称:Naru,代码行数:8,代码来源:UnhandledExceptionHandler.cs

示例12: UnobservedTaskExceptionHandler

		private static void UnobservedTaskExceptionHandler(object sender, UnobservedTaskExceptionEventArgs args) {
			if (args?.Exception == null) {
				Logging.LogNullError(nameof(args) + " || " + nameof(args.Exception));
				return;
			}

			Logging.LogFatalException(args.Exception);
		}
开发者ID:Kasp42,项目名称:ArchiSteamFarm,代码行数:8,代码来源:Program.cs

示例13: TaskScheduler_UnobservedTaskException

 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();
 }
开发者ID:binki,项目名称:Alba.Framework,代码行数:8,代码来源:UnhandledExceptionsHandler.cs

示例14: UnobservedException

 static void UnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
 {
     if (Debugger.IsAttached)
     {
         // An unobserved exception has occurred; break into the debugger
         Debugger.Break();
     }
 }
开发者ID:henricj,项目名称:HttpClientBackgroundAudio,代码行数:8,代码来源:AudioPlayer.cs

示例15: OnUnhandledExceptionRaised

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

            e.SetObserved();
        }
开发者ID:MechanicalMen,项目名称:Mechanical2,代码行数:8,代码来源:UnobservedTaskExceptionSource.cs


注:本文中的System.Threading.Tasks.UnobservedTaskExceptionEventArgs类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。