无需多说,直接上代码
using System;
using System.Diagnostics;
using System.Threading;
public class CpuLoadInfo
{
// auxiliary print methods
private static void Say ( string txt )
{
Console.WriteLine(txt);
}
// auxiliary print methods
private static void Say()
{
Say("");
}
// The main method. Command line arguments are ignored.
[STAThread]
public static void Main()
{
Say("$Id: CpuLoadInfo.cs,v 1.2 2002/08/17 17:45:48 rz65 Exp $");
Say();
Say("Attempt to create a PerformanceCounter instance:");
Say("Category name = " + CategoryName);
Say("Counter name = " + CounterName);
Say("Instance name = " + InstanceName);
PerformanceCounter pc = new PerformanceCounter(CategoryName,CounterName,InstanceName);
Say("Performance counter was created.");
Say("Property CounterType: " + pc.CounterType);
Say();
Say("Property CounterHelp: " + pc.CounterHelp);
Say();
Say("Entering measurement loop.");
while (true)
{
Thread.Sleep(1000); // wait for 1 second
float cpuLoad = pc.Nextvalue();
Say("CPU load = " + cpuLoad + " %.");
}
}
// constants used to select the performance counter.
private const string CategoryName = "Processor";
private const string CounterName = "% Processor Time";
private const string InstanceName = "_Total";
}
F5就可以看到运行结果了
分享到:
相关推荐
C#非wmi获取CPU处理器使用率,各核心使用率。
使用VB C语言 获取电脑CPU使用率,小巧实用,小内存使用,堪比鲁大师(说笑而已),完全代码公开,全解注释,直接F5运行,完全自己手动编写,适合有兴趣的猿员人们研究,桌面显示实时监控!!CPU使用率源代码,CPU使用...
C# 获取网络流量与CPU使用率,C# 获取网络流量与CPU使用率,感兴趣的赶紧下载
用c#代码实现,cpu实时利用率显示!!
C#获取CPU以及内存使用率的程序,有源码,使用Visual Studio 2013编译以及在Windows 8下调试。 蓝奏云下载链接:https://gfdgdxi.lanzous.com/b01nmiq4f 百度网盘下载链接:...
当有了进程对象后,可以通过进程对象名称来创建PerformanceCounter类型对象,通过设定PerformanceCounter构造函数的参数实现获取特定进程的CPU和内存使用情况。 具体实例代码如下: 首先是获取本机中所有进程对象,...
C#获取CPU、内存、硬盘当前使用百分比函数。
C#开发的操作系统任务进程信息监控 CPU使用率 内存使用率 和操作系统的任务管理器功能基本相同。希望对大家有所帮助。
自己写的控制台应用程序,获取的硬件信息2秒检测一次生成XML保存下来
delphi 通过调用C#的dll获取系统的cpu占用率,支持32和64位系统
该程序主要示意了ProcessorCounter和ManagementClass获取WMI参数,通过Processcounter获取CPU使用率,通过ManagementClass 获取物理内存即可用内存
通過調用OpenHardwareMonitor獲取電腦CPU溫度,使用率,內存使用率,風扇轉速,硬盤溫度及使用率,必須使用管理員權限
WMI获取远程服务器CPU,内存使用率函数源代码,主要解决Win32_LogicalMemoryConfiguration不能用的问题
查看cpu使用率顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶顶淡淡的
监控系统所有进程的CPU使用情况 显示CPU占用大于0的进程,定时刷新 可以查看当前系统运行的各进程cpu占用率 在CSDN上找到两个都不太好用,自己写了一个VS2013环境下编译通过 也可以直接运行\bin\Debug目录下的...
内存使用率、总CPU百分比、获得物理总内存(、获得可用内存(G)、获取mac地址、获取分区信息使用空间 进程(XX)CPU百分比、进程(XX)占用的内存大小、进程(XX)占用的内存百分比。 PerformanceCount方面比较详细,...
《Windows系统CPU内存网络性能统计第三篇 CPU 多核CPU各核使用率 C#》 http://blog.csdn.net/morewindows/article/details/8678382 配套程序,能获取多核CPU各核的使用率,已经测试,能在WinXP及Win7运行。
根据进程ID获取进程的内存使用量,CPU使用率,线程个数据信息,GetSysInfo
C#获取电脑cpu占有率,硬盘的使用率等的catername、instancname程序,用visual studio 2008编程的