I'm working on a piece of library code around IDisposable
. The managed path (via using
) is easily testable. I'm wondering about the finalizer though: Is calling System.GC.Collect()
sufficient to force the finalizer to run?
No, the GC.Collect() call is asynchronous, you would also need to call this:
System.GC.WaitForPendingFinalizers();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With