Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 internal LogItemEventArgs(LogItem item, Exception ex)
 {
     m_item = item;
     m_ex = ex;
 }
Ejemplo n.º 3
0
 private static void Log(LogItem info, Exception ex)
 {
     System.Diagnostics.Debug.Assert(!String.IsNullOrEmpty(info.Message));
     OnLogEventCaptured(new LogItemEventArgs(info, ex));
 }