Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Question..

 

Why does this.Close() exit and dispose the main application form, yet on newly created forms (Form frm = new Form();) the Close() method doesn't automatically dispose the form, only hides it?

Gamer extraordinaire. Programmer wannabe.
  • *Gurus*
Posted

The way .NET Windows Forms apps are initially set up, the program's message loop depends on the first form shown. Therefore, when it is closed there's no way the program can remain running any UI elements.

 

Application.Run() when called without any parameters sets up the message loop so it doesn't rely on any one form being open, but it does have the side effect that you have to terminate your message loop manually using Application.Exit() when all forms have been closed.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...