protected override void Dispose(bool disposing)
 {
     try
     {
         if (disposing)
         {
             if (PerformanceCounters.PerformanceCountersEnabled)
             {
                 if (null != this.Counters)
                 {
                     for (int ctr = this.PerfCounterStart; ctr < this.PerfCounterEnd; ++ctr)
                     {
                         PerformanceCounter counter = this.Counters[ctr];
                         if (counter != null)
                         {
                             PerformanceCounters.ReleasePerformanceCounter(ref counter);
                         }
                         this.Counters[ctr] = null;
                     }
                     this.Counters = null;
                 }
             }
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }
示例#2
0
        internal static void Set(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long value)
        {
            PerformanceCounter counter = null;

            try
            {
                if (counters != null)
                {
                    counter = counters[counterIndex];
                    if (counter != null)
                    {
                        counter.RawValue = value;
                    }
                }
            }
            catch (Exception exception)
            {
                if (Fx.IsFatal(exception))
                {
                    throw;
                }
                PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
                counters[counterIndex] = null;
                PerformanceCounters.ReleasePerformanceCounter(ref counter);
            }
        }
        static internal void Set(this PerformanceCountersBase thisPtr, PerformanceCounter[] counters, int counterIndex, long value)
        {
            PerformanceCounter counter = null;

            try
            {
                if (counters != null)
                {
                    counter = counters[counterIndex];
                    if (counter != null)
                    {
                        counter.RawValue = value;
                    }
                }
            }
#pragma warning suppress 56500 // covered by FxCOP
            catch (Exception e)
            {
                if (Fx.IsFatal(e))
                {
                    throw;
                }
                PerformanceCounters.TracePerformanceCounterUpdateFailure(thisPtr.InstanceName, thisPtr.CounterNames[counterIndex]);
                counters[counterIndex] = null;
                PerformanceCounters.ReleasePerformanceCounter(ref counter);
            }
        }
 protected override void Dispose(bool disposing)
 {
     try
     {
         if ((disposing && PerformanceCounters.PerformanceCountersEnabled) && (this.Counters != null))
         {
             for (int i = this.PerfCounterStart; i < this.PerfCounterEnd; i++)
             {
                 PerformanceCounter counter = this.Counters[i];
                 if (counter != null)
                 {
                     PerformanceCounters.ReleasePerformanceCounter(ref counter);
                 }
                 this.Counters[i] = null;
             }
             this.Counters = null;
         }
     }
     finally
     {
         base.Dispose(disposing);
     }
 }