Last active
August 11, 2021 14:45
-
-
Save ChaseFlorell/ba0aaea74f5b60faa96273b0adbe75c7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Reactive.Disposables; | |
namespace cannect.Core | |
{ | |
public class DisposableObject : ICancelable | |
{ | |
public bool IsDisposed { get; private set; } | |
public void Dispose() | |
{ | |
DisposeCheck(true); | |
GC.SuppressFinalize(this); | |
} | |
protected virtual void Dispose(bool disposing) | |
{ | |
if (disposing) | |
{ | |
TrashBin.Dispose(); | |
} | |
} | |
protected CompositeDisposable TrashBin { get; } = new(); | |
private void DisposeCheck(bool disposing) | |
{ | |
if (IsDisposed) | |
{ | |
return; | |
} | |
Dispose(disposing); | |
IsDisposed = true; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment