techsuppoprt
asked on
Closing initial Login Form from Program.cs
Morning Experts,
I'm having a bit of a brain fart. I think there is something small that I'm missing yet need help.
So.. pretty simple scenario:
Windows form app, Login window, which should be closed once user is authorized and the actual MDI application is presented.
I modified the Program.cs file for the Login form to be displayed before the main application comes up ( code below ).
The authentication works but the Login form doesn't go away unless I close it separately. The only way it works right now If I authenticate and then close the form by hitting the Cancel button.
Any suggestions ?
Thank you in advance.
I'm having a bit of a brain fart. I think there is something small that I'm missing yet need help.
So.. pretty simple scenario:
Windows form app, Login window, which should be closed once user is authorized and the actual MDI application is presented.
I modified the Program.cs file for the Login form to be displayed before the main application comes up ( code below ).
The authentication works but the Login form doesn't go away unless I close it separately. The only way it works right now If I authenticate and then close the form by hitting the Cancel button.
Any suggestions ?
Thank you in advance.
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Login userLogin = new Login();
while (!userLogin.UserIsAuthenticated && userLogin.LoginAttempts<3)
{
if (userLogin.ShowDialog() == DialogResult.Cancel)
{
break;
}
}
if (userLogin.UserIsAuthenticated)
{
Application.Run(new Main());
}
}
}
ASKER
No,doesn't work.
That's the thing, it doesn't get to this "if (userLogin.UserIsAuthentic ated)" block of code at all unless the form is closed or Canceled.
Any ideas ?
That's the thing, it doesn't get to this "if (userLogin.UserIsAuthentic
Any ideas ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
if (userLogin.UserIsAuthentic
{
Login.close();
Application.Run(new Main());
}