How to reset custom Performance Counter

夙愿已清 提交于 2019-12-23 07:29:11

问题


I have created a custom performance counter using the following code:

public class PerfCounter
{
    private PerformanceCounter perfCounter;

    PerfCounter(string CategoryName, string CounterName)
    {
        perfCounter = new PerformanceCounter(CategoryName, CounterName, false);
        perfCounter.BeginInit();
    }

    public void IncrementBy(long value)
    {
        perfCounter.IncrementBy(value);
    }

    public void Reset()
    {
        //what should I add here?
    }
}

Everything works fine but I don't know how to Reset the counter. Can anyone help me?


回答1:


Do this:

public void Reset()
{
    perfCounter.RawValue = 0;
}


来源:https://stackoverflow.com/questions/9585363/how-to-reset-custom-performance-counter

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