I'm looking for a way to sneak a call back function whenever an object reference has been garbage collected.
I know I can wrap the object in a weak reference, but I would still have to poll a collection of references for status change.
I would prefer not to poll as that seems like a waste of CPU cycle when nothing happens. Is there a more effective method to detect when an object has been garbage collected?
Note: I do not have access to the object code and hence would not be able to add the call back in the finalizer.