I'm new to Stack Overflow.
I'd thought I'd start with a puzzling question. How can I monitor the system and detect when new processes are created and when they are closed.
I wouldn't have the slightest idea on how to do this other that a constantly refreshing listbox polling System.Diagnostics.Process.GetProcesses() every second.
I need a monitor that fires an event when a new process is added and a seperate event that fires when a process is closed.
I'm not looking for a process monitor that runs on a loop or a timer. I need a direct interface to the process list, so this thread .NET Process Monitor Does not answer my question. Ideas?
-- Caustic
I would use TraceEvent, to start a Realtime Session and activate provider Microsoft-Windows-Kernel-Process
In the code you can see the ProcessStart
and ProcessStop
handling and here you can add your own code to handle when you get this data.