Releasing Classes

  • Thread starter Thread starter Dominic
  • Start date Start date
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
 
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
 
Back
Top