Question born of curiosity here:
How would I go about being notified or polling, to see when a process is currently being terminated?
So my application could listen out for a “termination begin” event from a process, for example, to track how long a particular process takes to close on average?
Note, this isn’t in conjunction with my process flipping the kill switch, that would be simple yes, but my application would act only as an observer.
Any help would be greatly appreciated 🙂
The only way I know for you to do this without polling is through WMI. There are plenty of examples on the web, e.g. Using WMI to monitor process creation, deletion and modification in .NET.
WMI is well wrapped by the .net libraries. For example, the sample above uses
ManagementEventWatcherto subscribe to WMI events. There’s a whole treasure trove of WMI goodness in theSystem.Managementnamespace.