When i stop the debugging in windows application the exe of a project
is shown as running in task manager
how to dispose it thru code?
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Sam HobbsPosted Jun 26, 2011, 12:13 AM
The better solution is to figure out why the program does not exit and fix the problem. That way it is possible to avoid making the same mistake in the future.
What type of program is it? Is it a console program or a Windows Forms program or something else? It is probably a Windows Forms program and a form is not being closed.
Krishna GaradPosted Jun 25, 2011, 6:09 AM
AmolPosted Jun 25, 2011, 6:08 AM
thanks krishna
Krishna GaradPosted Jun 25, 2011, 6:00 AM
private void KillProcess()
{
Boolean isAlive = true;
while (isAlive == true)
{
foreach (Process runningProcess in System.Diagnostics.Process.GetProcesses())
{
if (runningProcess.ProcessName == "name of exe")
{
runningProcess.Kill();
}
else
{
isAlive = false;
}
}
}
}