本文整理汇总了C#中System.Threading.Tasks.UnobservedTaskExceptionEventArgs.SetObserved方法的典型用法代码示例。如果您正苦于以下问题:C# UnobservedTaskExceptionEventArgs.SetObserved方法的具体用法?C# UnobservedTaskExceptionEventArgs.SetObserved怎么用?C# UnobservedTaskExceptionEventArgs.SetObserved使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Threading.Tasks.UnobservedTaskExceptionEventArgs
的用法示例。
在下文中一共展示了UnobservedTaskExceptionEventArgs.SetObserved方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: 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();
}
示例3: OnUnobservedTaskException
protected override void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
logger.Error(e.Exception);
e.SetObserved();
base.OnUnobservedTaskException(sender, e);
}
示例4: TaskScheduler_UnobservedTaskException
static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
var exception = e.Exception.Flatten();
Logger.Error(exception);
}
示例5: OnUnhandledExceptionRaised
private void OnUnhandledExceptionRaised( object sender, UnobservedTaskExceptionEventArgs e )
{
var handler = this.ExceptionCaught;
if( handler.NotNullReference() )
handler(e.Exception);
e.SetObserved();
}
示例6: 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();
}
示例7: handleUnObservedExceptions
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;
});
}
示例8: taskSchedulerUnobservedTaskException
void taskSchedulerUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
e.Exception.Flatten().Handle(ex =>
{
AppMessenger.Messenger.NotifyColleagues("ShowLog", ex.Message);
return true;
});
}
示例9: Tasks_UnobservedTaskException
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);
}
示例10: TaskScheduler_UnobservedTaskException
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);
}
示例11: OnTaskSchedulerUnobservedTaskException
// 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();
}
}
}
示例12: TaskSchedulerOnUnobservedTaskException
private void TaskSchedulerOnUnobservedTaskException(object sender,
UnobservedTaskExceptionEventArgs
unobservedTaskExceptionEventArgs)
{
if (Debugger.IsAttached)
Debug.WriteLine(unobservedTaskExceptionEventArgs.Exception.Message);
else
{
MessageBox.Show(unobservedTaskExceptionEventArgs.Exception.Message);
}
unobservedTaskExceptionEventArgs.SetObserved();
}
示例13: TaskScheduler_UnobservedTaskException
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);
}
}
示例14: TaskScheduler_UnobservedTaskException
private static void TaskScheduler_UnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
e.SetObserved();
HandleException(e.Exception);
}
示例15: OnUnobservedTaskException
private static void OnUnobservedTaskException(object sender, UnobservedTaskExceptionEventArgs e)
{
Console.WriteLine(e.Exception.GetBaseException());
e.SetObserved();
}