Click here to Skip to main content
15,908,111 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
Hi,

Can anyone help me with the code of killing the application on exit.


Thanks in advance.
Posted
Comments
Fabio V Silva 23-May-11 7:32am    
Which mobile device?
Legor 23-May-11 7:56am    
Please improve your question.
Thanks in advance.
Sergey Alexandrovich Kryukov 23-May-11 9:49am    
Why killing it? What kind of application, UI library you used (if any).
--SA
Saumyavemula 24-May-11 2:10am    
I am exiting application but when application is runned 2nd time and closed that time it is showing an error of Memory full. So i need to kill the application when clciked on exit.

1 solution

When you successfully exit any application, its process will be terminated, so it should not be killed. There is no such concept as "kill application" for all kinds of application I ever saw. You can only kill the process you're running.

In .NET it's calling System.Diagnostics.Process.GetCurrentProcess.Kill(). If you really need to do it, it means you are in deep trouble — you process keeps hanging after you exit the application (whatever it means; you did not share this information).

On reason for that could be unfinished threads. It does not happen to background threads, so this problem won't appear if you're using the thread pool, but decent application should better correctly exit or abort all threads before exiting from the application. There could be other reasons for hanging the process after exit of the application, often related to 3rd-party code referenced or P/Invoked, due to incorrect clean-up or just a bug. In all such cases, this is the indication of that you're in big trouble.

—SA
 
Share this answer
 
Comments
Saumyavemula 24-May-11 2:11am    
When my application is executed for 2nd time and closed that time it's showing an error of Memory full. What i should do??
Sergey Alexandrovich Kryukov 24-May-11 21:51pm    
I told you you're in trouble. You should find and fix a bug, that all I can answer based on your information. It needs investigation. You also abuse and/or leak memory.
--SA

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