11 ms·
As someone who has worked in C# for about 8 years: you can't. You can call `GC.Collect()` and hope. But far as I know the GC will do a best effort and gives no
by sobani 9y ago
As someone who has worked in C# for about 8 years: you can't.
You can call `GC.Collect()` and hope. But far as I know the GC will do a best effort and gives no guarantees.
Of course that's besides that fact that I would need strong arguments to accept a `GC.Collect()` anywhere in the code. But to call it just to ensure an object is collected? Oh boy..
Depending on the case you could add some code to the `Dispose(bool)` method to know when your object is collected, but also in that case you risk flipping a Bozo bit.