Skip to content

Instantly share code, notes, and snippets.

@chrisnas
Last active June 30, 2021 16:08
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 chrisnas/b466ef20374ee4f0e12afbe8de73e747 to your computer and use it in GitHub Desktop.
Save chrisnas/b466ef20374ee4f0e12afbe8de73e747 to your computer and use it in GitHub Desktop.
private void Cleanup(bool fromGC)
{
if (_disposed)
return;
try
{
// always clean up the NATIVE resources
if (fromGC)
return;
// clean up managed resources ONLY if not called from GC
}
finally
{
_disposed = true;
if (!fromGC)
GC.SuppressFinalize(this);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment