Home > Dev, Windows > Should I call Form.Dispose() after Form.Close() ?

Should I call Form.Dispose() after Form.Close() ?

I bet most of .NET developers do not realized this part of MSDN documentation. It cost me 100%CPU usage for not knowing this.

 

http://msdn.microsoft.com/en-us/library/system.windows.forms.form.close.aspx
*The two conditions when a form is not disposed on Close is when (1) it is part of a multiple-document interface (MDI) application, and the form is not visible; and (2) you have displayed the form using ShowDialog. In these cases, you will need to call Dispose manually to mark all of the form’s controls for garbage collection

 

Important Quotes:

The two conditions when a form is not disposed on Close is when

(1) it is part of a multiple-document interface (MDI) application, and the form is not visible; and

(2) you have displayed the form using ShowDialog. In these cases, you will need to call Dispose manually to mark all of the form’s controls for garbage collection.

Advertisements
Categories: Dev, Windows
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: