本文整理汇总了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);
}
}
示例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);
}
示例3: OnUnobservedTaskException
protected override void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
logger.Error(e.Exception);
e.SetObserved();
base.OnUnobservedTaskException(sender, e);
}
示例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);
}
示例5: AudioPlayer_UnobservedException
void AudioPlayer_UnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
{
Debug.WriteLine("AudioPlayer UnobservedException {0}", e.Exception.Message);
if (Debugger.IsAttached)
Debugger.Break();
}
示例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();
}
示例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();
}
示例8: TaskSchedulerOnUnobservedTaskException
private static void TaskSchedulerOnUnobservedTaskException(object sender,
UnobservedTaskExceptionEventArgs unobservedTaskExceptionEventArgs)
{
var newExc = new Exception("TaskSchedulerOnUnobservedTaskException",
unobservedTaskExceptionEventArgs.Exception);
LogUnhandledException(newExc);
}
示例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.");
}
}
}
示例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();
}
示例11: TaskScheduler_UnobservedTaskException
static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
var exception = e.Exception.Flatten();
Logger.Error(exception);
}
示例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);
}
示例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();
}
示例14: UnobservedException
static void UnobservedException(object sender, UnobservedTaskExceptionEventArgs e)
{
if (Debugger.IsAttached)
{
// An unobserved exception has occurred; break into the debugger
Debugger.Break();
}
}
示例15: OnUnhandledExceptionRaised
private void OnUnhandledExceptionRaised( object sender, UnobservedTaskExceptionEventArgs e )
{
var handler = this.ExceptionCaught;
if( handler.NotNullReference() )
handler(e.Exception);
e.SetObserved();
}