I for one do not like the design you proposed, would want to first show the Login form, then the mainform. But if you absolutely need it, then you can do the below..
In Main class:
Application.Run(new frmMain());
And then in Form class:
private void frmMain_Load(object sender, EventArgs e)
{
//---------------------------------------------
System.Windows.Forms.Timer t = new System.Windows.Forms.Timer();
t.Tick +=new EventHandler(t_Tick);
t.Interval = 1000;
t.Start();
}
void t_Tick(object sender, EventArgs e)
{
frmLogin l = new frmLogin();
if (l.ShowDialog(this) == DialogResult.Ok)
((System.Windows.Forms.Timer)sender.Dispose();
}
Though you have to further ensure that the login form is not exited without proper username and password (that should be upto you)
Use System.Windows.Forms.Timer because it runs in the same thread and hence would block the calls to main form (unlike System.Timers.Timer)