示例#1
0
 internal EndpointPerformanceCounters(string service, string contract, string uri) : base(service, contract, uri)
 {
     this.Counters = new PerformanceCounter[0x13];
     for (int i = 0; i < 0x13; i++)
     {
         PerformanceCounter endpointPerformanceCounter = PerformanceCounters.GetEndpointPerformanceCounter(EndpointPerformanceCountersBase.perfCounterNames[i], base.instanceName);
         if (endpointPerformanceCounter == null)
         {
             break;
         }
         try
         {
             endpointPerformanceCounter.RawValue = 0L;
             this.Counters[i] = endpointPerformanceCounter;
         }
         catch (Exception exception)
         {
             if (Fx.IsFatal(exception))
             {
                 throw;
             }
             if (DiagnosticUtility.ShouldTraceError)
             {
                 TraceUtility.TraceEvent(TraceEventType.Error, 0x80038, System.ServiceModel.SR.GetString("TraceCodePerformanceCounterFailedToLoad"), null, exception);
             }
             break;
         }
     }
 }
        internal EndpointPerformanceCounters(string service, string contract, string uri)
            : base(service, contract, uri)
        {
            this.Counters = new PerformanceCounter[(int)PerfCounters.TotalCounters];
            for (int i = 0; i < (int)PerfCounters.TotalCounters; i++)
            {
                PerformanceCounter counter = PerformanceCounters.GetEndpointPerformanceCounter(perfCounterNames[i], this.instanceName);
                if (counter != null)
                {
                    try
                    {
                        counter.RawValue = 0;
                        this.Counters[i] = counter;
                    }
#pragma warning suppress 56500 // covered by FxCOP
                    catch (Exception e)
                    {
                        if (Fx.IsFatal(e))
                        {
                            throw;
                        }
                        if (DiagnosticUtility.ShouldTraceError)
                        {
                            TraceUtility.TraceEvent(TraceEventType.Error, TraceCode.PerformanceCounterFailedToLoad,
                                                    SR.GetString(SR.TraceCodePerformanceCounterFailedToLoad), null, e);
                        }
                        break;
                    }
                }
                else
                {
                    break;
                }
            }
        }