Skip to content

Instantly share code, notes, and snippets.

@peterdew
Last active March 30, 2021 12:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peterdew/9f0ec99d79cf9f18ac8724fe20696977 to your computer and use it in GitHub Desktop.
Save peterdew/9f0ec99d79cf9f18ac8724fe20696977 to your computer and use it in GitHub Desktop.
standad dispose pattern
#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
@peterdew
Copy link
Author

peterdew commented Apr 3, 2019

@walsjewouter Dit standaard dispose-pattern hebben we afgesproken.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment