private static void OnLogEventCaptured(LogItemEventArgs info)
{
// Cache the value because events are not thread safe.
EventHandler<LogItemEventArgs> handler = LogEventCaptured;
if (handler == null)
{
return;
}
try
{
handler(null, info);
}
catch (Exception e)
{
// If we are in the process of reporting an ReportError and we get
// an exception, don't rethrow. It's possible that one of the handlers
// is in a terrible state. Rethrowing might lead to an infinite loop.
if (0 == String.CompareOrdinal(LogItemCategory.ReporterError, info.LogItem.Category))
{
return;
}
LogItem info2 = new LogItem(
LogItemType.Error,
LogItemCategory.ReporterError,
"Error handling routine threw an exception during processing.",
e);
Log(info2, e);
}
}