【问题标题】:How to reset custom Performance Counter如何重置自定义性能计数器
【发布时间】:2012-03-06 14:15:31
【问题描述】:

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

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?
    }
}

一切正常,但我不知道如何重置计数器。谁能帮帮我?

【问题讨论】:

标签: c# visual-studio-2010 performancecounter


【解决方案1】:

这样做:

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-12-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-08
    • 1970-01-01
    • 2021-05-30
    相关资源
    最近更新 更多