The challenge here is what form you pass to the Application.Run() method. If you start the application with an instance of the login form and then close that form I believe the application will exit. No doubt there are several ways to handle this...
One way is to pass an instance of your main form to the Application.Run method (this ties the message loop to that form instance and not the login form). In the OnLoad method of the main form you can use a modal dialog to perform the login. i.e.
//--Main form's OnLoad method
protected override void OnLoad(EventArgs ea)
{
// Remember to call base implementation
base.OnLoad(ea);
using( frmLogin frm = new frmLogin() )
{
if( frm.ShowDialog() != DialogResult.OK )
{
//--login failed - exit the application
Application.Exit();
}
}
}