Using System;
Using System. Collections. Generic;
Using System. Linq;
Using System. Text;
// Reference 2 namespace
Using System. Diagnostics;
Using System. Threading;
Namespace ConsoleApplication1
{
Class Program
{
Static void Main (string [] args)
{
Process [] p = Process. GetProcessesByName ("devenv"); // obtain the information of a specified Process
// Process [] p = Process. GetProcesses (); // obtain information about all processes
String cpu = string. Empty;
String info = string. Empty;
PerformanceCounter pp = new PerformanceCounter (); // Performance Counter
Pp. CategoryName = "Process"; // specify to obtain computer Process information. If the Processor parameter is passed, the system queries the computer CPU.
Pp. CounterName = "% Processor Time"; // shares
// If pp. CategoryName = "Processor", you can assign this parameter pp. InstanceName = "_ Total" Here to query the Total CPU of the computer.
Pp. InstanceName = "devenv"; // specifies the process
Pp. MachineName = ".";
If (p. Length> 0)
{
Foreach (Process pr in p)
{
While (true) // read the CPU usage once per second.
{
Info = pr. ProcessName + "memory:" +