Application.Run - message loop

M

Mark Denardo

Can someone explain the difference between starting an application using
Application.Run() and using ShowDialog?

Module MainModule
Sub Main
Dim f1 as New Form1
Application.Run(f1)
End Sub
End Module

vs.

Module MainModule
Sub Main
Dim f1 as New Form1
f1.ShowDialog()
End Sub
End Module

Also if someone can explain or point me to a good place that explains what
exactly a Message Loop is, that would be helpful. None of my books talk
anything about this stuff.
 
A

Armin Zingler

Mark Denardo said:
Can someone explain the difference between starting an application
using Application.Run() and using ShowDialog?

Module MainModule
Sub Main
Dim f1 as New Form1
Application.Run(f1)
End Sub
End Module

vs.

Module MainModule
Sub Main
Dim f1 as New Form1
f1.ShowDialog()
End Sub
End Module

Application.Run internally calls f1.Show first.


- Using Showdialog, it automatically returns as soon as you set the Form's
DialogResult property.
- Using Showdialog, the Form is not disposed automatically. You'd have to
call f1.Dispose additionally.
- Using Showdialog, clicking the "X" does not mean that the Form is closed,
it's only hidden and can be reshown by calling ShowDialog again. Using
Application.Run, you'd have to create a new instance to show.

All information available via said:
Also if someone can explain or point me to a good place that
explains what exactly a Message Loop is, that would be helpful. None of my
books talk anything about this stuff.


http://msdn.microsoft.com/library/e...erface/windowing/messagesandmessagequeues.asp

Especially about message loops (look for headline "Message Handling"):
http://msdn.microsoft.com/library/d...erface/windowing/messagesandmessagequeues.asp



Armin
 

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