Application.Run

  • Thread starter Thread starter Paul Aspinall
  • Start date Start date
P

Paul Aspinall

Hi
I have an app which starts using Application.Run(...........);

I want to create a logon screen, prior to the main app running, so I
modified my main() to look similar to

frmLogon logon = new frmLogon();

logon.ShowDialog();


//Check for valid logon

// If valid logon, start the main app

Application.Run(new frmMain());

logon=null;





My question is..... why do I need to use Application.Run ??

Should my logon prompt reside IN the application.run form, or outside it??



Thanks



Paul
 
Application.Run() handles the Windows message loop for frmMain().
Without it, your form won't be responsive to user input. As for
logon.ShowDialog(), modal dialogs have their own message loop, so it
really doesn't matter where you put it. However, you might want to
explicitly pass the owner of the dialog as a paremeter to ShowDialog().
In that case, you need to put it inside the form.

Oh, and for modal dialogs, you need to call Close/Dispose(), they
aren't disposed when the user closes them.

Regards
Senthil
 
Back
Top