Class DisposeBase
Base class for a IDisposable interface implementation with reference-counting semantics.
[DataContract]
public abstract class DisposeBase : IDisposable, IReferencable
- Inheritance
-
objectDisposeBase
- Implements
- Derived
- Extension Methods
Remarks
A class inheriting from DisposeBase is an implementation of IDisposable where calls to Dispose() decrements an internal reference count (following also IReferencable).
Only when that reference count reaches zero, the object should be disposed and the Destroy() method is invoked. That method can be overriden by derived classes to release dependent resources.
Properties
IsDisposed
Gets a value indicating whether the object has been disposed.
public bool IsDisposed { get; }
Property Value
Methods
Destroy()
Disposes the object's resources.
protected virtual void Destroy()
Remarks
Override in a derived class to implement disposal logic specific to it.
This method is automatically called whenever a call to Dispose() (or to Release()) has decreased the internal reference count to zero, meaning no other objects (hopefully) hold a reference to this one and its resources can be safely released.
Dispose()
Decrements the reference count of this object, disposing, releasing, and freeing associated resources when the count reaches zero.
public void Dispose()
- See Also
OnAddReference()
Called when a new reference of this object has been counted (via a call to AddReference()).
protected virtual void OnAddReference()
OnReleaseReference()
Called when a call to Release() has decremented the reference count of this object.
protected virtual void OnReleaseReference()