.Net에서 PerformanceCounters [PC]를 모니터링하는 카운터 검사 응용 프로그램이 있습니다.PerformanceCounters : 알 수없는 나쁜 동작
PerformanceCounterCategory pcc = new PerformanceCounterCategory(this.categoryName, this.machineName);
if(pcc.CounterExists(this.counterName))
{
if(this.pc != null) //Could exist from earlier use.
{
try
{
this.pc.Close();
this.pc.Dispose();
}
catch(Exception ex)
{
...log
}
}
this.pc = new PerformanceCounter(this.categoryName, this.counterName, this.instanceName, this.machineName);
float value = pc.NextValue(); //Initial read//////-----MARK-----.
}
이 코드는 초기 잘 작동합니다
나는 등 동기화 액세스 할 수 있도록 PC에 대한 래퍼 클래스를 사용하고 CounterWrapper 다음 코드가 실행되는 초기화 방법을 가지고 있습니다. 감시 컴퓨터 중 하나 후
는 오프라인 -이 업데이트 방법 내부에 등록 된 경우 - 위의 코드는 더 이상 작동하지 않으며, 그 반대의 원격 가용성, 위의 "초기화"메서드를 다시 호출을 테스트 할 수 있습니다. 때로는 이것이 작동하지만 때로는 실패합니다. 실패하면 다음과 같이 표시됩니다.
InvalidOperation; 메시지 : 닫힌 레지스트리 키에 액세스 할 수 없습니다. 개체 이름 : 'HKEY_PERFORMANCE_DATA'., 출처 : mscorlib
위의 코드에서 MARKed 위치에 있습니다.
PerformanceCounterCategory pcc = new PerformanceCounterCategory(this.categoryName, this.machineName);
if(pcc.CounterExists(this.counterName))
또는 여기 : "초기화"에서
this.pc = new PerformanceCounter(this.categoryName, this.counterName, this.instanceName, this.machineName);
하지만하지를 "값 = this.pc.NetxtValue"[표시된 pos의
나는 코드가 여기에 실패 할 것으로 예상했다 ]
프레임 워크에 이상한 일이있는 것 같습니다. [그리고 처음으로 퍼포먼스 커넬에서 이상하게 보입니다.]
도움이 될 것입니다.
덕분에 지금까지와 안부,
++ mabra
오, 내 자신의 feets, 내가 볼 :-(.... 고마워요! – mabra
그것보다 더 새 라인을 얻을 수 없다. –
pcc는하지만 PC는 아니지만 나는 말할 수있다. –