Here. “Basically the class keeps track of the list of outstanding handles, and when it reaches a certain threshold it can force a GC. Basically the goal here is to do a cheap and easy extension to the GC to try and teach it about the relative expensive of unmanaged objects.”
This is the way that GDI+ deals with unmanaged resource reclamation and can be used for your own non-memory resources.