System.Transactions.Transaction.DependentClone C# (CSharp) Method

DependentClone() public method

public DependentClone ( DependentCloneOption cloneOption ) : DependentTransaction
cloneOption DependentCloneOption
return DependentTransaction
        public DependentTransaction DependentClone(
            DependentCloneOption cloneOption
            )
        {
            TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
            if (etwLog.IsEnabled())
            {
                etwLog.MethodEnter(TraceSourceType.TraceSourceLtm, this);
            }

            if (cloneOption != DependentCloneOption.BlockCommitUntilComplete
                && cloneOption != DependentCloneOption.RollbackIfNotComplete)
            {
                throw new ArgumentOutOfRangeException(nameof(cloneOption));
            }

            if (Disposed)
            {
                throw new ObjectDisposedException(nameof(Transaction));
            }

            if (_complete)
            {
                throw TransactionException.CreateTransactionCompletedException(DistributedTxId);
            }

            DependentTransaction clone = new DependentTransaction(
                _isoLevel, _internalTransaction, cloneOption == DependentCloneOption.BlockCommitUntilComplete);

            if (etwLog.IsEnabled())
            {
                etwLog.TransactionCloneCreate(clone, "DependentTransaction");
                etwLog.MethodExit(TraceSourceType.TraceSourceLtm, this);
            }
            return clone;
        }

Same methods

Transaction::DependentClone ( System cloneOption ) : System.Transactions.DependentTransaction

Usage Example

Example #1
0
        // SetCurrent
        //
        // Place the given value in current by whatever means necessary for interop mode.
        private void SetCurrent(Transaction newCurrent)
        {
            // Keep a dependent clone of current if we don't have one and we are not committable
            if (_dependentTransaction == null && _committableTransaction == null)
            {
                if (newCurrent != null)
                {
                    _dependentTransaction = newCurrent.DependentClone(DependentCloneOption.RollbackIfNotComplete);
                }
            }

            switch (_interopOption)
            {
            case EnterpriseServicesInteropOption.None:
                _threadContextData.CurrentTransaction = newCurrent;
                break;

            case EnterpriseServicesInteropOption.Automatic:
                EnterpriseServices.VerifyEnterpriseServicesOk();
                if (EnterpriseServices.UseServiceDomainForCurrent())
                {
                    EnterpriseServices.PushServiceDomain(newCurrent);
                }
                else
                {
                    _threadContextData.CurrentTransaction = newCurrent;
                }
                break;

            case EnterpriseServicesInteropOption.Full:
                EnterpriseServices.VerifyEnterpriseServicesOk();
                EnterpriseServices.PushServiceDomain(newCurrent);
                break;
            }
        }
All Usage Examples Of System.Transactions.Transaction::DependentClone