Close Method

  • Thread starter Thread starter Ivan Weiss
  • Start date Start date
I

Ivan Weiss

Hi all, this might be a dumb question but I know the .NET framework
handles garbage collection a lot different than VB6.

In my close button on a form I have:
Me.Close()

Will this destroy the object or just close it? Will all resources it
used be returned to the system or do I need to call finalize and/or
dispose?

Thanks,

-Ivan Weiss
 
Ivan Weiss said:
Hi all, this might be a dumb question but I know the .NET
framework handles garbage collection a lot different than VB6.

In my close button on a form I have:
Me.Close()

Will this destroy the object or just close it?

Will all resources
it used be returned to the system or do I need to call finalize
and/or dispose?


Me.Close closes and disposes the window. You don't need to call Dispose. The
object still lives, but it is a disposed object. The object dies when the
last reference has been removed and the GC collects the object.
 
You don't need to call finalize or close. If your form is the main form,
the application will close. You only really need to mess around with
dispose if you are referencing interoped components (like COM objects), to
remove references etc. before you shutdown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top