My application consists of main message loop (GUI) and threads (Task.Factory).
In the threads I call some 3rd party applications with var p = new Process();
But when I invoke Application.Exit();
in the message loop - I can see that the processes, that were started in the threads are still in the memory and are being executed.
So the question is - how to kill all the threads and Processes right after Application.Exit();
has been invoked?
UPD:
old:
p.WaitForExit();
new:
while (!p.WaitForExit(1000))
{
if (FlagToExit)
{
p.Kill();
return;
}
}