Dot.NET References

From PeformIQ Upgrade
Revision as of 05:50, 17 October 2021 by PeterHarding (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Destructors and Dispose

Public class MyClass:IDisposable
{
 private bool IsDisposed=false;
 public void Dispose()
 {
  Dispose(true);
  GC.SupressFinalize(this);
 }
 protected void Dispose(bool Diposing)
 {
  if(!IsDisposed)
  {
  if(Disposing)
  {
   //Clean Up managed resources

  }
  //Clean up unmanaged resources

 }
 IsDisposed=true;
 }
 ~MyClass()
 {
  Dispose(false);
 }
}