PC Review


Reply
Thread Tools Rate Thread

Disposing of Forms...

 
 
=?Utf-8?B?QW50aG9ueSBOeXN0cm9t?=
Guest
Posts: n/a
 
      14th May 2004
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
 
Reply With Quote
 
 
 
 
Armin Zingler
Guest
Posts: n/a
 
      15th May 2004
"Anthony Nystrom" <(E-Mail Removed)> schrieb
> 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

 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      15th May 2004
* =?Utf-8?B?QW50aG9ueSBOeXN0cm9t?= <(E-Mail Removed)> scripsit:
> 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>

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      15th May 2004
Hi Anthony,

In addition to Armin and Herfried,

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

Cor


 
Reply With Quote
 
Herfried K. Wagner [MVP]
Guest
Posts: n/a
 
      15th May 2004
* "Cor Ligthert" <(E-Mail Removed)> scripsit:
> 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.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Forms not completely disposing... =?Utf-8?B?Qm9iYnkgQ2Fubm9u?= Microsoft Dot NET Compact Framework 7 16th May 2007 04:48 PM
Disposing of Windows Forms Henry Jones Microsoft VB .NET 3 3rd Nov 2006 03:43 AM
disposing forms Naim Rizk Microsoft Dot NET Compact Framework 2 5th Nov 2004 05:42 AM
Disposing of Forms. AP Microsoft C# .NET 9 3rd Mar 2004 05:25 PM
disposing child forms CJack Microsoft Dot NET Framework Forms 0 25th Dec 2003 09:20 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:56 PM.