Click here to Skip to main content
15,892,199 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am using .NET 3.5. now i completed my window application project with single instance. everything is fine but when user close the form, still it was running. every time we have to end the process from task manager

my process flow is following...

1) Login form
2) after successfull log in login form will be hide main form will be shown
3) if user trying to close main form, still login form was running...we are not supposed to close login form

Can u help me any one????
Posted
Comments
Francisco T. Chavez 10-Jun-13 1:48am    
Is this a WinForm application or a WPF application?
Balasubramanian T 10-Jun-13 1:59am    
WinForm application

Write down following code on Unload event of your Main Page. May be it will solve ur problem

Application.Exit();
 
Share this answer
 
Hi,

While closing the main form event write :

C# Closing Applications[^]
Application.Exit Method[^]
 
Share this answer
 
v2
Comments
Balasubramanian T 31-May-13 6:03am    
thank u for Your Solution...
its working fine in Exit button(button which is created by Developer)
but when i click windows default close buttons,its not working...
Rockstar_ 31-May-13 6:23am    
There will be some other events will there form closing event , just write the same code in that event also...
Check you star up Form.
You need to close that to close you application if that form is hidden in background so your process is still running.
You can use application.exit() to close you application.
You can check you stat up Form in project property application tab.

Another option that you can specify is that change shutdown mode in application tab to when last form is close.
 
Share this answer
 
Write below code under formclosing event
C#
private void sample_FormClosing(object sender, FormClosingEventArgs e)
{
     Application.Exit();
}



Thank U All
 
Share this answer
 
v2

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