8

Is there a way of checking if an object was collected by the Garbage Collector in .NET?

I'm trying to write an API that'll hook onto some events of objects that are passed in, and I need to make sure I don't use strong references to the object. I know how to do this, but I'd also like to write a unit test to verify this, and that I don't know how to do.

Cameron MacFarland
  • 70,676
  • 20
  • 104
  • 133
  • This sounds a bit crazy.. what do you actually want to do? What do you want to test? – tarn Mar 12 '09 at 04:42
  • Needing to check for strong object reference usage does sound unusual. What are you actually trying to do? – Mitch Wheat Mar 12 '09 at 04:43
  • Hook up to a NotifyPropertyChanged event in an object passed into a watcher class. If the original object is disposed then the watcher should just drop the reference from it's watch list. – Cameron MacFarland Mar 12 '09 at 04:49

0 Answers0