Releasing Classes

D

Dominic

Hi,

I've a separated class DOIT with a function WATCH which is
dynamically creating FileSystemWatchers.

In an other project I'm creating a new instance of DOIT
and start my function WATCH. So far so good....

I'm setting the Instance DOIT later in the application to
NOTHING, but all created FileSystemWatchers are still
running. How can I release/dispose a whole instanced class
within a project ? Or how can I kill all
FileSystemWatchers at one time (but I d'ont know how many
there are) ?

Many thanks for any help !
Cheers,
Dominic
 
J

Jay B. Harlow [MVP - Outlook]

Dominic,
I would have the DOIT class implement the IDisposable interface. Instead of
setting the DOIT variable to Nothing, I would call the DOIT.Dispose method.
Within the Dispose method I would have it "shut down" each of the
FileSystemWatchers, that this instance of the DOIT class created earlier.

This may mean that DOIT would need an internal ArrayList to hold each
instance of any dynamically created FileSystemWatchers that were created.

Hope this helps
Jay
 

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

Top