Exemplo n.º 1
0
        public void ExceptionsThrownInTheConstructorFailGracefully()
        {
            BrokenObject broken = null;

            try
            {
                broken = new BrokenObject();
            }
            catch (Exception)
            {
            }
            finally
            {
                broken?.Dispose();
                broken = null;
            }

            // trigger the finalizer
            CollectGarbage();
        }
Exemplo n.º 2
0
        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();
        }