Beispiel #1
0
 private PerformanceCounter CounterFromConfig(PerfCounterConfig config)
 {
     PerformanceCounter counter;
     if (MultipleInstance)
         counter = new PerformanceCounter(Category, config.Name, ConfigUtility.ApplicationName, false);
     else
         counter = new PerformanceCounter(Category, config.Name, false);
     counter.RawValue = config.RawValue;
     return counter;
 }
 private PerformanceCounter CounterFromConfig(string instance, PerfCounterConfig config)
 {
     try
     {
         PerformanceCounter counter;
         if (MultipleInstance)
         {
             if (instance == null)
                 counter = new PerformanceCounter(Category, config.Name, ConfigUtility.ApplicationName, false);
             else
                 counter = new PerformanceCounter(Category, config.Name, instance, false);
         }
         else
             counter = new PerformanceCounter(Category, config.Name, false);
         counter.RawValue = config.RawValue;
         return counter;
     }
     catch (Exception ex)
     {
         return null;
     }
 }