5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

[C#] タスクマネージャに近いCPU使用率の取得

Last updated at Posted at 2020-06-10

teratailに回答したもので、比較的使えそうなやつシリーズ。
teratail- C#でCPUの使用率を取得してWPFで表示したい。

#コード
※ System.Management アセンブリ参照を追加すること。

var searcher = new System.Management.ManagementObjectSearcher("select LoadPercentage from CIM_Processor");
foreach (var obj in searcher.Get())
{
    var val = obj["LoadPercentage"];
    Console.WriteLine("LoadPercentage : " + val);
}
5
5
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
5

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?