// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Diagnostics; using System.Threading; namespace E { public class Program { public static void Main(string[] args) { while(true) { Process[] p = Process.GetProcessesByName("firefox"); if(p.Length > 0) { Process p0 = p[0]; long t1 = DateTime.Now.Ticks; long p0t1 = p0.TotalProcessorTime.Ticks; Thread.Sleep(100); long t2 = DateTime.Now.Ticks; long p0t2 = p0.TotalProcessorTime.Ticks; int pct = (int)(100 * (p0t2 - p0t1) / (t2 - t1)); Console.WriteLine(pct); } else { break; } } } } }