public void ExceptionsThrownInTheConstructorFailGracefully() { BrokenObject broken = null; try { broken = new BrokenObject(); } catch (Exception) { } finally { broken?.Dispose(); broken = null; } // trigger the finalizer CollectGarbage(); }
public void ExceptionsThrownInTheConstructorFailGracefully() { BrokenObject broken = null; try { broken = new BrokenObject(); } catch (Exception) { } finally { broken?.Dispose(); broken = null; } // try and trigger the finalizer GC.Collect(); GC.WaitForPendingFinalizers(); }