Skip to content

Instantly share code, notes, and snippets.

@chrisnas
Created January 12, 2019 18:54
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/8d2528ae525f46a2281e93d2d54a295a to your computer and use it in GitHub Desktop.
Save chrisnas/8d2528ae525f46a2281e93d2d54a295a to your computer and use it in GitHub Desktop.
public class PhantomObjectFinalizer : PhantomReference<LargeObject>
{
private int _handle;
public PhantomObjectFinalizer(ReferenceQueue<LargeObject> queue, LargeObject value)
: base(queue, value)
{
_handle = value.Handle;
}
public void FinalizeResources()
{
Console.WriteLine("I'm cleaning handle " + _handle);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment