Click here to Skip to main content
15,616,232 members
Please Sign up or sign in to vote.
1.86/5 (3 votes)
See more:
I am designing wpf application... My problem is that on window closing i want to kill the task in the task manager ... Can anyone please help me out.
Updated 13-Nov-21 18:04pm
Ziee-M 6-Nov-13 1:42am    
When closing your form, the application should handle closing process in the task Manager, if it dosent, then you have some ressources used that blocks the application from terminating.
You should dispose all disposable ressources and terminates your application threads in the form closing event!
jing567 6-Nov-13 1:44am    
how to dispose all that threads yar... I am new to this please provide me if you have any sample snippet
Ziee-M 6-Nov-13 2:01am    
Share your code or some of it, otherwise no one can help you!

Share this answer
Have you tried using process.Kill() to kill process in task manager

using System.Diagnostics;
 foreach (Process proc in Process.GetProcessesByName("OUTLOOK"))

Hope it helps you.
Share this answer
jing567 6-Nov-13 4:59am    
Hello Keerth,
Can you help me that how to get the exact name of my application ... Dont laugh at my question.. I am placing my app name but i am unable to get the process
keerth516 6-Nov-13 6:23am    
ha ha ha...okay normally WPF app running in task manager will appear as appName.vshot.exe

and am not sure what is your purpose of doing it.
jing567 6-Nov-13 7:13am    
Hi Keerth,
My requirement is that whenever I close my window application , the service that is associated to that application should be killed... thats what my requirement....
Just Place ane event in the xaml code


Then write a event handler for that closing event in .cs page


private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)

Share this answer

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900