Created
January 12, 2019 20:57
-
-
Save chrisnas/f1e29d9aa9565e2c33ce4d9d063797e0 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
public class LargeObject : IDisposable | |
{ | |
private static readonly Cleaner<LargeObject, NativeState> _cleaner; | |
static LargeObject() | |
{ | |
_cleaner = new Cleaner<LargeObject, NativeState>(Cleanup, OnError); | |
} | |
private NativeState _state; | |
// Plus some heavy stuff that we don't want to keep around once the object is no more referenced | |
public LargeObject() | |
{ | |
_state = new NativeState() | |
{ | |
_handle1 = (IntPtr) (DateTime.Now.Ticks), | |
_handle2 = (IntPtr) (DateTime.Now.Ticks + 1), | |
}; | |
_cleaner.Track(this, _state); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment