I have an application that launches another program and monitors it. When the program closes, my application also closes.
However, if I close my application first, the other program is still running.
ProcessStartInfo procInfo = new ProcessStartInfo("myProg.exe");
Process proc = new Process();
proc.StartInfo = procInfo;
proc.Start();
while (!proc.HasExited)
{
// do stuff
}
// On proc exit, my application is also done
How do I make sure that if I close my monitoring app, any processes that are being monitored are also killed?
So for example suppose MyApp is monitoring Notepad. If I close MyApp, Notepad should also be closed.