this.Close() (form method)

wyrd

Well-known member
Joined
Aug 23, 2002
Messages
1,408
Location
California
Question..

Why does this.Close() exit and dispose the main application form, yet on newly created forms (Form frm = new Form();) the Close() method doesnt automatically dispose the form, only hides it?
 
The way .NET Windows Forms apps are initially set up, the programs message loop depends on the first form shown. Therefore, when it is closed theres no way the program can remain running any UI elements.

Application.Run() when called without any parameters sets up the message loop so it doesnt 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.
 
Back
Top