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

when i close the form by clicking X (close), when i debug the application tracing is as follows:
C#
private void Form1_FormClosing(object sender, FormClosingEventArgs e)
       {
           Application.Exit();
       }

and next goes to DIspose()
C#
protected override void Dispose(bool disposing)
       {
           if (disposing && (components != null))
           {
               components.Dispose();
           }
           base.Dispose(disposing);
       }

next goes to program.cs
C#
Application.Run(ConnectObj);
statement

and my application is runnung background how to exit the application when i click cancel at top of the form

form is closed but in task manager it is running. how to exit
Posted
Updated 4-May-14 23:33pm
v2
Comments
OriginalGriff 5-May-14 5:23am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
We have no idea what "application" you are talking about running in the background...
Use the "Improve question" widget to edit your question and provide better information.
Member 10263519 5-May-14 5:35am    
how to exit the application , i used application.Exit(). but it's not exit the application.
my application is having two threads
José Amílcar Casimiro 5-May-14 5:42am    
You need to stop the threads or wait until they are complete and then the process is closed.
Sergey Alexandrovich Kryukov 5-May-14 7:52am    
Let me note that you accepted a totally wrong solution, Solution 1. Don't do such things. You need to provide more information.
How to exit application? Call Application.Exit().
—SA

1 solution

if you have background processes, try
C#
System.Diagnostics.Process.GetCurrentProcess().Kill();

for more information Refer this Answers[^]
 
Share this answer
 
v2
Comments
Member 10263519 5-May-14 5:44am    
thanq

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