public FormMain() { InitializeComponent(); Main = this; SuperPower.Enable(); _self = Process.GetCurrentProcess(); _processes = new Processes(); UpdateTitle(); _icons = new Icon[15]; _miniChart = new MiniChart(); Application.ApplicationExit += HandleApplicationExit; _processors = Environment.ProcessorCount; _cpuIdCounter = new PerformanceCounter[_processors]; _miniChartCpuId = new MiniChart[_processors]; for (int p = 0; p < _processors; p++) { _cpuIdCounter[p] = new PerformanceCounter("Processor", "% Processor Time", p.ToString()); _miniChartCpuId[p] = new MiniChart(); } _theCPUCounter = new PerformanceCounter("Processor", "% Processor Time", "_Total"); _trayIcon = new NotifyIcon(); _trayIcon.DoubleClick += (o, e) => ToggleWindowVisibility(); LoadIcons(); BuildMenu(); UpdateTrayIcon(); _totalCpuMode = true; UpdateVisualizationMode(); _timer = new Timer { Interval = 1000 }; _timer.Tick += HandleTick; _timer.Start(); }
public ProcessObserver(int pid, string name) { Pid = pid; _name = name; _timer = new Timer(); _timer.Interval = 1000; _timer.Tick += HandleTimerTick; _hndl = Kernel32.OpenSimple(Pid); _chart = new MiniChart(); _process = Process.GetProcessById(pid); _process.EnableRaisingEvents = true; _process.Exited += HandleProcessExited; _chart.Dock = DockStyle.Fill; InitForm(); _form.Show(); UpdateTitle(); Start(); }