PerformanceCounter cpu = new PerformanceCounter("Processor", "% Processor Time", "_Total");
PerformanceCounter memory = new PerformanceCounter(".NET CLR Memory", "# Bytes in all Heaps", Application.ProductName);
PerformanceCounter memoryHeap = new PerformanceCounter("Memory", "% Committed Bytes In Use", "");
构造的第一个参数是类别名称,也就是“管理工具”里的“性能”里计数器的对象名,第二个参数是计数器名,对应“性能”里的计数器名,第三个参数是你想跟踪的实例名,一般是_Total或_Global_,某些情况下也可以是你的应用程序名称。你可以在“性能”里添加一个计数器,在弹出的对话框中有可以选择的实例名称。