资料来源:网络整理
时间:2023/2/14 1:11:41 共计:3669 浏览
static void Main(string[] args)
{
Console.WriteLine("查看进程CPU使用情况");
system_cpu();
Console.ReadKey();
}
/// <summary>
/// 创建性能计数器
/// </summary>
/// <param name="pname"></param>
static void system_cpu()
{
using (PerformanceCounter system_cpu_usage = new PerformanceCounter("Processor", "% Processor Time", "_Total"))
{
while (true)
{
var first = system_cpu_usage.NextValue();
//注意除以CPU数量
Console.WriteLine(first + "%");
Thread.Sleep(1000);
}
}
}

版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。