2015-09-12 26 views
7

C#で特定のサービスのCPU使用率を知りたい。サービスとC#で特定のサービスのCPU使用率を取得する

PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "myprocess", true); 
double result = counter.NextValue(); 

ではなく:プロセスと正常に動作しますPerformanceCounter

PerformanceCounter counter = new PerformanceCounter("Service", "% Processor Time", "myservice", true); 
    double result = counter.NextValue(); 
+0

サービスがあまりにもプロセスです –

+0

私は"試してみた" PerformanceCounter counter =新しいPerformanceCounter( "Process"、 "%Processor Time"、 "myservice"、true); – userfloflo

+0

サービスのCPU使用率を取得するには double result = counter.NextValue(); "myServiceを使用しないで、実際の名前を使用すると、変更が問題を隠しています –

答えて

4

パフォーマンスカウンターの正しい名前は次のようになり

PerformanceCounter counter = new PerformanceCounter("Process", "% Processor Time", "ACService", true); 
関連する問題