using System;
using System.Diagnostics;
class ProcessMonitorSample
{
public static void Main()
{
Process myProcess = null;
myProcess = Process.Start("NotePad.exe");
do
{
if (!myProcess.HasExited)
{
myProcess.Refresh();
Console.WriteLine("{0} -", myProcess.ToString());
Console.WriteLine("physical memory usage: {0}",myProcess.WorkingSet64);
Console.WriteLine("base priority: {0}",myProcess.BasePriority);
Console.WriteLine("priority class: {0}",myProcess.PriorityClass);
Console.WriteLine("user processor time: {0}",myProcess.UserProcessorTime);
Console.WriteLine("privileged processor time: {0}",myProcess.PrivilegedProcessorTime);
Console.WriteLine("total processor time: {0}",myProcess.TotalProcessorTime);
Console.WriteLine("PagedSystemMemorySize64: {0}",myProcess.PagedSystemMemorySize64);
Console.WriteLine("PagedMemorySize64: {0}",myProcess.PagedMemorySize64);
Console.WriteLine(myProcess.PeakPagedMemorySize64);
Console.WriteLine(myProcess.PeakVirtualMemorySize64);
Console.WriteLine(myProcess.PeakWorkingSet64);
if (myProcess.Responding)
{
Console.WriteLine("Status = Running");
}
else
{
Console.WriteLine("Status = Not Responding");
}
}
}
while (!myProcess.WaitForExit(1000));
Console.WriteLine("Process exit code: {0}",myProcess.ExitCode);
}
}
|