I am just starting .Net development (C#) and have come across some code that has me slightly confused....
If I have
Form myForm = new Form();
Application.Run(myForm);
makes that form visible to user. It is the first form which get loaded in memory. And it runs this form in a message loop, so that you get all user events.
Short Answer:
Application.Run begins running a standard application message loop on the current thread.
Long Answer:
Application.Run
causes the windows application enters the message loop within Winmain to process various windows messages the OS posts to a message queue.The message loop, "Loops" until its receives a WM_QUIT message. It uses GetMessage
and PeekMessage
to retrive messages and PostMessage
to sent the retrived messages to Windows procedure.
If you do
Form myForm = new Form();
myForm.Show();
it will show the form and exit out. You will use new Form()
& .Show()
when you want to launch a new form from existing form.
Hope this answers your question.