Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I have designed a log-in screen for getting the application started.

Now when I enter the user name and password and Click on the Log in Button, I hide the Log in page and display the Main Menu form (Which is an Mdi Form and all forms open on same Mdi form).

Now when I am closing the main menu form, the whole application is getting closed but the application does not exit completely. A process is continually running.

what do I do to stop the application?

I think this is happening because I am hiding (not Closing) the log in page.
Posted
Updated 7-Jul-10 23:02pm
v2

Yes, that's right. Redesign your app so your main form IS your main form, or call Application.PostQuitMessage, or something along those lines, instead of closing your form and expecting your app to close itself. I forget the exact call, and I am on my Mac ( and google is no help ), but it's on the Application object, I am sure.
 
Share this answer
 
Comments
Yatin Bhagat 8-Jul-10 5:19am    
There is application.exit() method...
Call this function under FormClosed Event of Mdi Parent Form,and
pass the name of process(.exe) as a parameter.

using System.Diagnostics;
public void FindAndKillProcess(string name)
{

foreach (Process clsProcess in Process.GetProcesses())
{

if (clsProcess.ProcessName.StartsWith(name))
{
clsProcess.Kill();

}
}

}
 
Share this answer
 
Comments
DaveyM69 8-Jul-10 5:31am    
Nasty! Killing processes is almost never the correct thing to do, especially when it's a basic design issue that can be fixed through a little code alteration.
Instead of hiding the login form do something similar to what is illustrated in this tip/trick:

Multiple Subsequent Main Forms in C# Apps[^]

The root problem, however, is that you may have left a thread running or some other thing is not being cleaned up when exiting the application. I would search out the real cause of the problem instead of trying band-aids and workarounds.

Your only friend in this is the debugger built in Visual Studio.
 
Share this answer
 

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


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