public Exception HandleException(Exception exception, IDictionary bizInfo)
 {
     try
     {
         LogManager.GetLogger("ExceptionLogger").Error(exception, bizInfo);
     }
     catch (Exception ex)
     {
         EffectiveFileLogger.WriteException(exception);
         EffectiveFileLogger.WriteException(ex);
     }
     return(exception);
 }
 public Exception HandleException(Exception exception, Guid handlingInstanceId, IDictionary bizInfo)
 {
     try
     {
         LogManager.GetLogger(this.LogCategory).WriteMessage(this.LogLevel, bizInfo, exception);
     }
     catch (Exception ex)
     {
         EffectiveFileLogger.WriteException(exception);
         EffectiveFileLogger.WriteException(ex);
     }
     return(exception);
 }
Пример #3
0
 public void Log(LogLevel level, object msg, Exception exception)
 {
     if (false == this.EnableTrace)
     {
         return;
     }
     try
     {
         LogManager.GetLogger(this.LogCategory).WriteMessage(level, msg, exception);
     }
     catch (Exception ex)
     {
         EffectiveFileLogger.WriteException(exception);
         EffectiveFileLogger.WriteException(ex);
     }
 }
Пример #4
0
 void SaveLogEntry(ILogEntry entry)
 {
     entry.WriteTime = DateTime.Now;
     this.listeners.ForEach(item =>
     {
         if (IsWriteForListener(entry.LogLevel, this.ListenerIndexes[item.Name]))
         {
             try
             {
                 item.WriteMessage(entry);
             }
             catch (Exception ex)
             {
                 EffectiveFileLogger.WriteException(ex);
             }
         }
     });
 }
Пример #5
0
        private void ExecuteWorkItem()
        {
#if !(_WINDOWS_CE) && !(_SILVERLIGHT)
            CallerThreadContext ctc = null;
            if (null != _callerContext)
            {
                ctc = CallerThreadContext.Capture(_callerContext.CapturedCallContext, _callerContext.CapturedHttpContext);
                CallerThreadContext.Apply(_callerContext);
            }
#endif

            Exception exception = null;
            object    result    = null;

            try
            {
                try
                {
                    result = _callback(_state);
                }
                catch (Exception ex)
                {
                    // Save the exception so we can rethrow it later
                    exception = ex;
                    try
                    {
                        new TaskThreadException(ex).HandleException();
                    }
                    catch
                    {
                        EffectiveFileLogger.WriteException(new TaskThreadException(ex));
                    }
                }

                // Remove the value of the execution thread, so it will be impossible to cancel the work item,
                // since it is already completed.
                // Cancelling a work item that already completed may cause the abortion of the next work item!!!
                Thread executionThread = Interlocked.CompareExchange(ref _executingThread, null, _executingThread);

                if (null == executionThread)
                {
                    // Oops! we are going to be aborted..., Wait here so we can catch the ThreadAbortException
                    Thread.Sleep(60 * 1000);

                    // If after 1 minute this thread was not aborted then let it continue working.
                }
            }
            // We must treat the ThreadAbortException or else it will be stored in the exception variable
            catch
            {
                // Check if the work item was cancelled
                // If we got a ThreadAbortException and the STP is not shutting down, it means the
                // work items was cancelled.
                if (!SmartThreadPool.CurrentThreadEntry.AssociatedSmartThreadPool.IsShuttingdown)
                {
#if !(_WINDOWS_CE) && !(_SILVERLIGHT)
                    Thread.ResetAbort();
#endif
                }
            }

#if !(_WINDOWS_CE) && !(_SILVERLIGHT)
            if (null != _callerContext)
            {
                CallerThreadContext.Apply(ctc);
            }
#endif

            if (!SmartThreadPool.IsWorkItemCanceled)
            {
                SetResult(result, exception);
            }
        }