Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/307.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何重置使用System.Diagnostics.PerformanceCounter添加的性能计数器_C#_System.diagnostics_Perfmon - Fatal编程技术网

C# 如何重置使用System.Diagnostics.PerformanceCounter添加的性能计数器

C# 如何重置使用System.Diagnostics.PerformanceCounter添加的性能计数器,c#,system.diagnostics,perfmon,C#,System.diagnostics,Perfmon,我继承了一个项目,该项目使用自定义性能计数器来监视IIS部署的web服务的成功/失败请求数及其处理时间。我用来记录计数器的代码如下所示: using (var performanceCounter = new PerformanceCounter() { CategoryName = MyConstants.Constants.PerformanceCountersRootName, CounterName = counterName, MachineName = "." }) { pe

我继承了一个项目,该项目使用自定义性能计数器来监视IIS部署的web服务的成功/失败请求数及其处理时间。我用来记录计数器的代码如下所示:

using (var performanceCounter = new PerformanceCounter() { CategoryName = MyConstants.Constants.PerformanceCountersRootName, CounterName = counterName, MachineName = "." })
{
    performanceCounter.ReadOnly = false;
    if (operationCounter != OperationCounter.ProcessingTime)
    {
        performanceCounter.Increment();
    }
    else
    {
        performanceCounter.RawValue = value;
    }
}
现在我的问题是如何在一段固定的时间后重置计数器,比如说每周重置一次。这里有一个类似的例子,但我的问题是我不想用代码重置计数器

我需要使用一些调度机制,可能是某种powershell脚本或windows调度或类似的机制

我已经检查过了,我觉得这不是适合我的方法。请建议

多谢各位


Ravi

使用powershell脚本或C#app运行每周计划任务,将
RawValue
设置为
0
谢谢Mathias听起来不错。我将通过powershell搜索如何执行此操作。如果你知道在你的头上,然后请张贴它作为答案,我会接受它。