Last active
June 30, 2021 16:11
-
-
Save chrisnas/0d68aa1ca411c5b5f59f75ec1ea035d7 to your computer and use it in GitHub Desktop.
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
class DisposableMe : IDisposable | |
{ | |
private bool _disposed = false; | |
// 1. field that implements IDisposable | |
// 2. field that stores "native resource" (ex: IntPtr) | |
~DisposableMe() | |
{ | |
Cleanup("called from GC" != null); | |
} // = true | |
public void Dispose() | |
{ | |
Cleanup("not from GC" == null); | |
} // = false | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment