System.Transactions.Tests.TransactionScopeTest.NestedTransactionScope12 C# (CSharp) Метод

NestedTransactionScope12() приватный Метод

private NestedTransactionScope12 ( ) : void
Результат void
        public void NestedTransactionScope12()
        {
            IntResourceManager irm = new IntResourceManager(1);

            Assert.Null(Transaction.Current);
            using (TransactionScope scope = new TransactionScope())
            {
                irm.Value = 2;

                using (TransactionScope scope2 = new TransactionScope())
                {
                    irm.Value = 4;
                    /* Not completing this, so the transaction will
                     * get aborted
                    scope2.Complete (); */
                }

                using (TransactionScope scope3 = new TransactionScope(TransactionScopeOption.RequiresNew))
                {
                    /* Using RequiresNew here, so outer transaction
                     * being aborted doesn't matter
                     */
                    scope3.Complete();
                }
            }
        }