Dispose,

  • Thread starter Thread starter cronusf
  • Start date Start date
C

cronusf

I have a managed class that contains objects that implement
IDisposable. So my class also implements IDisposable, and simply
calls the Dispose method for each object:

public void Dispose()
{
mMovieAVI.Dispose();
mMovieRT.Dispose();
}

Since my class doesn't contain any unmanaged resources directly, am I
correct that I do not need a finalizer?
 
If the class was marked as sealed, then I would say yes, this is fine.

If it is not sealed, then you should implement it the way suggested here
(for the base class, assuming this is the first class in the hierarchy that
implements IDisposable) so that classes that derive from yours have a chance
to hook into the dispose call chain:

http://msdn.microsoft.com/en-us/library/b1yfkh5e.aspx
 
Back
Top