Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to reset custom Performance Counter

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?

like image 519
chaliasos Avatar asked Feb 03 '23 07:02

chaliasos


1 Answers

Do this:

public void Reset()
{
    perfCounter.RawValue = 0;
}
like image 112
Rian Schmits Avatar answered Feb 08 '23 12:02

Rian Schmits