私はPerformanceCounters [PC]を.Netから監視するカウンタチェックアプリケーションを持っています。PerformanceCounters:識別できない悪い動作
私は CounterWrapperは、以下のコードが実行されるInitメソッドを持っているなど、同期のアクセスを許可するPCのラッパークラスを使用しています:
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-----.
}
このコードは、初期うまく動作します。注目のコンピュータのいずれかの後
がオフラインになる - これは、Updateメソッド内で登録されている - 上記 のコードが動作しなくなるんやそのカウンターのリモート可用性をテストするために、上記 「初期化」メソッドが再び呼び出されます。場合によってはこれが機能することもありますが、失敗することもあります。それが失敗すると、私は参照してください:
InvalidOperation;メッセージ:閉じたレジストリキーにアクセスできません。 オブジェクト名: 'HKEY_PERFORMANCE_DATA'。ソース:mscorlib
これは上記コードのMARKされた位置にあります。
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の
私はコードがここで失敗すると予想しています]
フレームワークで何か変なことがあるようですが[これは初めてではありません。私はPerformanceCountersで何か変わったことがあります。
助けがあれば助かります。
おかげで、これまでと よろしく、
++ mabra
ああ、自分自身のfeets、私は見る:-(....ありがとうたくさん! – mabra
それは新しいことができませんそれ以上の行を取得します –
pccは、私が言うことができる。 –