NServiceBus.PerformanceCounterHelper.TryToInstantiatePerformanceCounter C# (CSharp) Method

TryToInstantiatePerformanceCounter() public static method

public static TryToInstantiatePerformanceCounter ( string counterName, string instanceName ) : IPerformanceCounterInstance
counterName string
instanceName string
return IPerformanceCounterInstance
        public static IPerformanceCounterInstance TryToInstantiatePerformanceCounter(string counterName, string instanceName)
        {
            PerformanceCounter counter;
            var success = TryToInstantiatePerformanceCounter(counterName, instanceName, out counter, false);
            if (success)
            {
                return new PerformanceCounterInstance(counter);
            }
            return new NonFunctionalPerformanceCounterInstance();
        }

Same methods

PerformanceCounterHelper::TryToInstantiatePerformanceCounter ( string counterName, string instanceName, PerformanceCounter &counter, bool throwIfFails ) : bool

Usage Example

Example #1
0
 public void Warmup()
 {
     messagesPulledFromQueueCounter = PerformanceCounterHelper.TryToInstantiatePerformanceCounter(
         "# of msgs pulled from the input queue /sec",
         queueName);
     successRateCounter = PerformanceCounterHelper.TryToInstantiatePerformanceCounter(
         "# of msgs successfully processed / sec",
         queueName);
     failureRateCounter = PerformanceCounterHelper.TryToInstantiatePerformanceCounter(
         "# of msgs failures / sec",
         queueName);
 }