User FAQs

If you have a question, please send it to us.


1) Can you describe the Dispose Pattern ?
This pattern provides a standard convention for working around the shortcomings of the Finalize method.
This pattern uses the System.IDisposable interface.

public class MyObject : System.IDisposable 
{
   bool _disposed;

   public void Dispose()
   {
      Dispose(true);
      GC.SuppressFinalize(this);
   }

   protected virtual void Dispose(bool disposeOfManaged)
   {
      if (this._disposed == false)
      {
         if (disposeOfManaged == true)
         {
            //code to clean up managed resources
            component.Dispose();
         }

         //code to clean up unmanaged resources

         this._disposed = true;
      }
   }

   protected override void Finalize()
   {
      Dispose(false);
   }
}


© 2021 Better Solutions Limited. All Rights Reserved. © 2021 Better Solutions Limited TopPrevNext