Beispiel #1
0
        public static PerformanceCounter CreateCounter(string categoryName, PerformanceCounterType counterType)
        {
            string counterName = categoryName + "_Counter";

            CounterCreationDataCollection ccdc = new CounterCreationDataCollection();
            CounterCreationData           ccd  = new CounterCreationData();

            ccd.CounterType = counterType;
            ccd.CounterName = counterName;
            ccdc.Add(ccd);

            Helpers.DeleteCategory(categoryName);
            PerformanceCounterCategory.Create(categoryName, "description", PerformanceCounterCategoryType.SingleInstance, ccdc);

            Helpers.VerifyPerformanceCounterCategoryCreated(categoryName);

            return(new PerformanceCounter(categoryName, counterName, readOnly: false));
        }