Application.Run(frmMain)

  • Thread starter Thread starter D Witherspoon
  • Start date Start date
D

D Witherspoon

Whats the purpose of

Application.Run(frmMain) in the Sub Main method.

Why not just...

Dim fMain as New frmMain
frmMain.Show()

???
 
D Witherspoon said:
Whats the purpose of

Application.Run(frmMain) in the Sub Main method.

Why not just...

Dim fMain as New frmMain
frmMain.Show()

Documentation on 'Application.Run':

| Begins running a standard application message loop on the
| current thread.

Showing a form by calling its 'Show' method doesn't do that.
 
D Witherspoon said:
Whats the purpose of

Application.Run(frmMain) in the Sub Main method.

Why not just...

Dim fMain as New frmMain
frmMain.Show()

???

It's used to set up the main message loop on the current thread. The message
loop is what handles incoming messages from windows (mouse was clicked, mouse
was moved etc) and turns them into events that you can handle.
Without it once the sub main has finished your application exits.

James
 
Application.Run(), begins running a standard application message loop on the
current thread taking as parameter the form that's going to be the main
entry point of your application. In change, the way you say only creates an
instance of a form, quicky display it and the exits.

Hope this may help you,

Regards,
 
Back
Top