获得特定进程信息

///
/// 获得特定进程信息
///
/// 进程名称
public static void GetProcessInfo(string processName)
{
Process[] processes = Process.GetProcessesByName(processName);
foreach (Process instance in processes)
{
Console.WriteLine("");
Console.WriteLine("ProcessName:" + instance.ProcessName);
try
{

//单位:KB
Console.WriteLine("提交大小\t" + instance.PagedMemorySize64 / 1024);
Console.WriteLine("工作设置(内存)\t" + instance.WorkingSet64 / 1024);
Console.WriteLine("线程数\t" + instance.Threads.Count);
Console.WriteLine("句柄数\t" + instance.HandleCount);

}
catch { }
}

//PerformanceCounter TotalCpuUsage = new PerformanceCounter("Process", "% Processor Time", "Idle");
//double total1 = 0;
//while (true)
//{
// if (total1 == 0)
// {
// total1 = processes[0].TotalProcessorTime.TotalMilliseconds;
// }
// else
// {
// total1 += processes[0].TotalProcessorTime.TotalMilliseconds - total1;
// }
// Thread.Sleep(1000);
//}
}




本文转自94cool博客园博客,原文链接:http://www.cnblogs.com/94cool/p/6307238.html,如需转载请自行联系原作者

上一篇:算术运算符


下一篇:通过一个App Demo的演示深入理解区块链运行原理