Click here to Skip to main content
13,249,174 members (32,642 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hello,
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.
Posted 5-Nov-13 18:20pm
jing5671.1K
Updated 5 days ago
Thanks7872135.7K
v2
Comments
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!
jing111 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!
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

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


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


Hope it helps you.
  Permalink  
Comments
jing111 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.
jing111 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....
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

Just Place ane event in the xaml code

Closing="Window_Closing"



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

Code:

private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
       {
           Application.Current.Shutdown();
 
       }
  Permalink  

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

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy |
Web04 | 2.8.171114.1 | Last Updated 13 Nov 2017
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100