Disposing of Forms...

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Anytime I close a form should I also dispose such as

me.clos
me.dispos

What else Should I dispose... If I set a var to nothing should I also dispose such as

f = nothin
f.dispos

Just curious??

Thanks

Anthony
 
Anthony Nystrom said:
Anytime I close a form should I also dispose such as:

me.close
me.dispose

What else Should I dispose... If I set a var to nothing should I also
dispose such as:

f = nothing
f.dispose

Just curious???

If there are objects to dispose, do it in Sub Dispose. As mentioned in the
other thread, you do not need to dispose the form. I must add that it
depends on whether the form has been shown modaly or modeless. If you close
a modal form (shown with Showdialog), it is not disposed automatically. You
can display the same Form instance again. Modeless Forms are disposed
automatically, and you have to create a new instance if you want to show the
Form again.

Concerning setting variables to Nothing: You can set it to Nothing as soon
as you don't need to use the variable again. It doesn't make sense to set it
to Nothing when the variable is destroyed anyway right after setting it to
nothing, like with local variables at the end of the procedure.


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
* =?Utf-8?B?QW50aG9ueSBOeXN0cm9t?= said:
Anytime I close a form should I also dispose such as:

me.close
me.dispose

MSDN on 'Form.Close':

<msdn>
When a form is closed, all resources created within the object are
closed and the form is disposed.
</msdn>
 
Hi Anthony,

In addition to Armin and Herfried,

What they write is for me one of the major advantages from Net

Cor
 
* "Cor Ligthert said:
In addition to Armin and Herfried,

What they write is for me one of the major advantages from Net

I think it was much easier in VB6, where you didn't have to worry about
disposing as much as in .NET.
 
Back
Top