Understanding of Dispose()

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

Guest

Hello

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

Thanks
Milan
 
Milan,

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

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.

http://msdn.microsoft.com/library/d...l/frlrfsystemidisposableclassdisposetopic.asp

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.

Cor
 
Back
Top