473,404 Members | 2,187 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

Disposing of Forms...

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
Nov 20 '05 #1
4 1116
* =?Utf-8?B?QW50aG9ueSBOeXN0cm9t?= <an************@genetibase.com> 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/>
Nov 20 '05 #2
"Anthony Nystrom" <an************@genetibase.com> 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

Nov 20 '05 #3
Hi Anthony,

In addition to Armin and Herfried,

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

Cor
Nov 20 '05 #4
* "Cor Ligthert" <no**********@planet.nl> 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/>
Nov 20 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Patrick De Ridder | last post by:
I have been looking at an example, and there is something I don't inderstand. Given: form1 calls form2 --------- Question: What is the use of having these lines in form2 --------------...
4
by: Dakkar | last post by:
I have a program with windows forms and after execution of my program im making it invisible for working background progress and i have a dispose function like this protected override void...
13
by: MuZZy | last post by:
Hi, Just wanted to make sure i get it right: consider this class: // =========== START CODE ============= class Test { private SqlConnection con = null; public void Connect() { con = new...
2
by: Dave | last post by:
I'm having trouble understanding dispose. I set up a class that, among other things, displays the time in a status bar panel. It does this by starting a thread. I create an instance of this...
5
by: Chris | last post by:
I have a form that requires drawing custom lines on it. The color of the lines is suppose to be the same as the forcolor of the form. Am I doing this the most efficent and correct way? ...
3
by: Henry Jones | last post by:
I have a project that has 5 or 6 forms. VB.NET VS 2005 In the FormClosing Event of each form I have the following code: If Not IsNothing(frmA) Or Not frmA.IsDisposed Then frmA.Close() If...
4
by: Peter Webb | last post by:
I am supposed to manually dispose of some instances, such as Brushes, right? I have a couple of questions: 1. I have the following code, and it works just fine: ...
29
by: Jerry Spence1 | last post by:
I'm rather confused as to whether something should be disposed of, or not. What is the general rule? How can you be sure of doing the right thing? I've heard about disposing unmanaged resources but...
2
by: libish | last post by:
hi all... i have an application... where i'm creating forms dynamically... once i created the forms what i'm doing is that, i'm calling formob.show(); here everything works perfect.. but the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.