Application.Run or not?

E

Erik Cruz

Hi.

Is there any benefits of using Application.Run in a Sub Main procedure to
start a windows application? I set a form as the startup object for all my
vb programs, but have seen several examples that starts an application by
using Application.Run in a Sub Main instead of define a form as the startup
object.

TIA,
Erik Cruz
 
A

Armin Zingler

Erik Cruz said:
Is there any benefits of using Application.Run in a Sub Main
procedure to start a windows application? I set a form as the startup
object for all my vb programs, but have seen several examples that
starts an application by using Application.Run in a Sub Main instead
of define a form as the startup object.

Whenever you set a form as the startup object, VB.NET creates an invisible
Sub Main that looks like this one:

shared sub main
application.run(new Form1())
end sub

Application.Run contains a message loop that processes the messages sent to
the application. This default Sub Main can be used if there is no code to be
executed before or after showing the main form, and if the Form is displayed
from the start til the end of the application.
 
H

Herfried K. Wagner [MVP]

* "Erik Cruz said:
Is there any benefits of using Application.Run in a Sub Main procedure to
start a windows application? I set a form as the startup object for all my
vb programs, but have seen several examples that starts an application by
using Application.Run in a Sub Main instead of define a form as the startup
object.

In addition to Armin's reply, have a look at the IL code of both
applications using "ildasm.exe".

--
Herfried K. Wagner
MVP · VB Classic, VB.NET
<http://www.mvps.org/dotnet>

Improve your quoting style:
<http://learn.to/quote>
<http://www.plig.net/nnq/nquote.html>
 

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

Similar Threads


Top