In article <uI**************@TK2MSFTNGP10.phx.gbl>, Bob Day wrote:
Using VS 2003, VB.Net, MSDE...
The example below from help shows that the Sub Main contains an explicit
Application.Run. Is this required? Are there pros and cons of doing it
this way? I have not been using application.run on my Main_Thread (i.e. sub
main) and it seems to be Ok.
Under what condistions should you explicityly put an application.run in a
sub main (ie Main_Thread)?
Please advise.
Shared Sub Main()
' Starts the application.
Application.Run(New Form1())
End Sub
Thanks!
If your starting a windows forms app from a sub main, then yes it is
required. Otherwise, your main form will appear and then close when the
main method exits. The application.Run method creates the message loop
for your main form, and also sets that form as the application context
- so when it closes the rest of the app closes. If you are using a form
as your startup object, VB just generates this code behind your back....
It is also possible to use the ShowDialog method of your main form from
the Sub Main - but that isn't really the recommended method.
--
Tom Shelton [MVP]
OS Name: Microsoft Windows XP Professional
OS Version: 5.1.2600 Service Pack 1 Build 2600
System Up Time: 0 Days, 0 Hours, 8 Minutes, 49 Seconds