By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,955 Members | 1,756 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,955 IT Pros & Developers. It's quick & easy.

Understanding of Dispose()

P: n/a

When Windows.Forms.Form procceds Dispose(), do it dispose all child controls
and fields?

I have Form variable Image which is connected to opened MemoryStrem (also
Form field)

When I call Form.Dispose(), does it mean that Image will be disposed and
MemoryStrem closed and disposed/distroyed

Mar 16 '06 #1
Share this Question
Share on Google+
1 Reply

P: n/a

The dispose is probably the method which gives the most discussion in these

Mainly because it is often read as a finalize method. That is it not. As the
ToString is it an overridable method. It is a method from Icomponentmodel
which is implemented in probably 80% of the most used classes (as Jon tested
once in 20% of the existent ones)

If you build your own classes than it is up to you what you do with it.

There are some classes where it is preferable that disposed is used. Think
for that on modal forms and drawing pens. In this is not the memory that is
occupied the most important but the used handles.

An object is released by the GC as part of the managed code as soon as it is
not needed anymore. This on a propriety time, however. Doing this all the
time would give worst performance.

I hope this gives an idea.

Mar 16 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.