Last active
March 30, 2021 12:55
-
-
Save peterdew/9f0ec99d79cf9f18ac8724fe20696977 to your computer and use it in GitHub Desktop.
standad dispose pattern
This file contains 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
#region Disposing | |
~ClassName() | |
{ | |
Dispose(false); | |
} | |
public bool IsDisposed { get; private set; } | |
public void Dispose() | |
{ | |
Dispose(true); | |
GC.SuppressFinalize(this); | |
} | |
protected virtual void Dispose(bool disposing) | |
{ | |
if (!disposing || IsDisposed) return; | |
producer?.Dispose(); | |
consumer?.Dispose(); | |
IsDisposed = true; | |
} | |
#endregion |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@walsjewouter Dit standaard dispose-pattern hebben we afgesproken.