My application consists of a main message loop (GUI) and threads (Task.Factory).
In threads, I call some third-party applications with var p = new Process();
But when I call Application.Exit();in the message loop, I see that the processes that were running in the threads are still in memory and are executing.
So the question is: how to kill all threads and processes immediately after the call Application.Exit();?
UPD
old:
p.WaitForExit();
new
while (!p.WaitForExit(1000))
{
if (FlagToExit)
{
p.Kill();
return;
}
}
source
share