C# 如何重置使用System.Diagnostics.PerformanceCounter添加的性能计数器
我继承了一个项目,该项目使用自定义性能计数器来监视IIS部署的web服务的成功/失败请求数及其处理时间。我用来记录计数器的代码如下所示: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
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搜索如何执行此操作。如果你知道在你的头上,然后请张贴它作为答案,我会接受它。