我用GetSystemInfo()获取到的全是CPU的型号和页面大小等信息,但我要想得到CPU当前的利用率应该怎么做呢???
解决方案 »
- C# 串口通信问题:
- VS 2008 控制台输出表格问题
- VS2008: 怎样在设计时用上WVGA(800*480)?
- 如何使用最佳算法判断一个字节数组中是否包含指定字节!
- VS2005 中的Task List中的User Tasks中的项有什么作用?
- 我用c#已经把面向对象的课程设计做了,可老师说只能用c++.有什么简单的方法用vc.net调用我的c#程序吗?
- treeview能不能与服务器上的某个路径(文件夹)绑订啊?有,应该怎么绑?
- 怎样取出ACESS数据库指定表中某行的某个字段值?
- web开发服务器段编程和客户段编程有什么区别各有什么优点
- 在打印预览中单击工具栏上的打印按钮时打印?
- 利用vs2005打包网站,附加数据库问题
- 两个datagridview 的传值问题
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";
}
http://blog.csdn.net/lhfzd2004/archive/2007/08/02/1722379.aspx
http://blog.csdn.net/lhfzd2004/archive/2007/08/01/1721687.aspx