IIsDisposable - Yortw/Yort.Trashy GitHub Wiki

IIsDisposable is a simple interface that allows code to interrogate an object instance to see if it has been disposed. It contains a single member, IsDisposed, which should return true if the object is disposed (or is in the process of being disposed).

The base classes already implement this interface, but it can be implemented manually. A naïve implementation follows.

   public class MyDisposable : IIsDisposed
   {
     private bool _IsDisposed;

     public bool IsDisposed { get { _IsDisposed; } }

     public void Dispose()
     {
       _IsDisposed = true;
     }
   }