2012-03-06 13 views
9

Ho creato un contatore delle prestazioni personalizzato utilizzando il seguente codice:Come resettare prestazioni personalizzato contatore

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

Tutto funziona bene, ma non so come azzerare il contatore. Qualcuno può aiutarmi?

+2

Forse questo aiuterà? http://stackoverflow.com/questions/9195851/reset-performance-counter-from-command-line – Freddy

risposta

13

fare questo:

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

Grazie, ha funzionato. – Schaliasos

+0

Prego :-) –

Problemi correlati