How can I add a performance counter to a category i have already created

早过忘川 提交于 2019-12-05 09:08:37

问题


I have created a PerformanceCounterCategory like below

var category = PerformanceCounterCategory.Create("MyCat", "Cat Help",
    PerformanceCounterCategoryType.SingleInstance, "MyCounter", "Counter Help);

How can I add a new counter to the category to monitor another item?
I cannot find the api for it.


回答1:


I did a research on this a while back and it doesn't seem to be possible to add counters to an existing category, what you would have to do it to recreate the same category with addition of the new counter.




回答2:


PerformanceCounter lCounter = new PerformanceCounter(Category, CounterName, 
                                                     false);
lCounter.MachineName = ".";


来源:https://stackoverflow.com/questions/958164/how-can-i-add-a-performance-counter-to-a-category-i-have-already-created

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!