如何重置自定义性能计数器

cha*_*sos 9 c# performancecounter visual-studio-2010

我使用以下代码创建了一个自定义性能计数器:

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?
    }
}
Run Code Online (Sandbox Code Playgroud)

一切正常,但我不知道如何重置柜台.谁能帮我?

Ria*_*its 12

做这个:

public void Reset()
{
    perfCounter.RawValue = 0;
}
Run Code Online (Sandbox Code Playgroud)