예제 #1
0
 protected virtual void RunThread(object state)
 {
     try
     {
         Recorder.Trace(2L, TraceType.InfoTrace, new object[]
         {
             "Executor.RunThread State:",
             state,
             "Synchronous:",
             this.IsSynchronous,
             "Current:",
             this.current
         });
         GrayException.MapAndReportGrayExceptions(delegate()
         {
             try
             {
                 if (this.IsSynchronous)
                 {
                     Interlocked.Increment(ref this.current);
                     this.RunTask(state);
                 }
                 else
                 {
                     foreach (object item in this.queue.GetConsumingEnumerable())
                     {
                         this.RunTask(item);
                     }
                 }
             }
             catch (OperationCanceledException)
             {
                 Recorder.Trace(2L, TraceType.WarningTrace, "Executor.RunThread OperationCancelled");
             }
             catch (SearchException ex2)
             {
                 Recorder.Trace(2L, TraceType.ErrorTrace, "Executor.RunThread Search Error:", ex2);
                 this.Cancel(ex2);
             }
         });
     }
     catch (GrayException ex)
     {
         Recorder.Trace(2L, TraceType.ErrorTrace, "Executor.RunThread Gray Error:", ex);
         this.Cancel(ex);
     }
     finally
     {
         Interlocked.Decrement(ref this.current);
         Recorder.Trace(2L, TraceType.InfoTrace, new object[]
         {
             "Executor.RunThread Completed Current:",
             this.current,
             "Cancelled:",
             this.IsCancelled
         });
         if (!this.IsCancelled)
         {
             this.AttemptComplete();
         }
     }
 }