Application.Run

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
 
S

sadhu

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top