DependentClone() public method

public DependentClone ( DependentCloneOption cloneOption ) : DependentTransaction
cloneOption DependentCloneOption
return DependentTransaction
コード例 #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;
            }
        }
コード例 #2
0
        private void SetCurrent(Transaction newCurrent)
        {
            if (((this.dependentTransaction == null) && (this.committableTransaction == null)) && (newCurrent != null))
            {
                this.dependentTransaction = newCurrent.DependentClone(DependentCloneOption.RollbackIfNotComplete);
            }
            switch (this.interopOption)
            {
            case EnterpriseServicesInteropOption.None:
                this.threadContextData.CurrentTransaction = newCurrent;
                return;

            case EnterpriseServicesInteropOption.Automatic:
                Transaction.VerifyEnterpriseServicesOk();
                if (!Transaction.UseServiceDomainForCurrent())
                {
                    this.threadContextData.CurrentTransaction = newCurrent;
                    return;
                }
                this.PushServiceDomain(newCurrent);
                return;

            case EnterpriseServicesInteropOption.Full:
                Transaction.VerifyEnterpriseServicesOk();
                this.PushServiceDomain(newCurrent);
                return;
            }
        }
コード例 #3
0
        internal TransactionWaitAsyncResult(Transaction transaction, PersistenceContext persistenceContext, TimeSpan timeout, AsyncCallback callback, object state)
            : base(callback, state)
        {
            bool completeSelf = false;
            TransactionException exception = null;
            this.PersistenceContext = persistenceContext;
            this.thisLock = new object();

            if (null != transaction)
            {
                // We want an "blocking" dependent transaction because we want to ensure the transaction
                // does not commit successfully while we are still waiting in the queue for the PC transaction
                // lock.
                this.dependentTransaction = transaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
            }
            else
            {
                this.dependentTransaction = null;
            }

            // Put a lock around this and Complete() in case the transaction we are queueing up behind
            // finishes and we end up calling Complete() before we actually finish constructing this
            // object by creating the DependentClone and setting up the IOThreadTimer.
            lock (ThisLock)
            {
                if (persistenceContext.QueueForTransactionLock(transaction, this))
                {
                    // If we were given a transaction in our constructor, we need to 
                    // create a volatile enlistment on it and complete the
                    // dependent clone that we created. This will allow the transaction to commit
                    // successfully when the time comes.
                    if (null != transaction)
                    {
                        // We are not going async, so we need to complete our dependent clone now.
                        this.dependentTransaction.Complete();

                        exception = this.CreateVolatileEnlistment(transaction);
                    }
                    completeSelf = true;
                }
                else
                {
                    // If the timeout value is not TimeSpan.MaxValue, start a timer.
                    if (timeout != TimeSpan.MaxValue)
                    {
                        this.timer = new IOThreadTimer(TimeoutCallbackAction, this, true);
                        this.timer.Set(timeout);
                    }
                }
            }

            // We didn't want to call Complete while holding the lock.
            if (completeSelf)
            {
                base.Complete(true, exception);
            }
        }
 protected SqlWorkflowInstanceStoreAsyncResult(System.Runtime.DurableInstancing.InstancePersistenceContext context, System.Runtime.DurableInstancing.InstancePersistenceCommand command, SqlWorkflowInstanceStore store, SqlWorkflowInstanceStoreLock storeLock, Transaction currentTransaction, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
 {
     this.DependentTransaction = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store = store;
     this.StoreLock = storeLock;
     this.TimeoutHelper = new System.Runtime.TimeoutHelper(timeout);
     base.OnCompleting = (Action<AsyncResult, Exception>) Delegate.Combine(base.OnCompleting, finallyCallback);
 }
 // ExtendLockAsyncResult and RecoverInstanceLocksAsyncResult directly call this ctor
 protected SqlWorkflowInstanceStoreAsyncResult
     (
     InstancePersistenceContext context,
     InstancePersistenceCommand command,
     SqlWorkflowInstanceStore store,
     SqlWorkflowInstanceStoreLock storeLock,
     Transaction currentTransaction,
     TimeSpan timeout,
     int maximumRetries,
     AsyncCallback callback,
     object state
     ) :
     base(callback, state)
 {
     this.DependentTransaction = (currentTransaction != null) ? currentTransaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete) : null;
     this.InstancePersistenceContext = context;
     this.InstancePersistenceCommand = command;
     this.Store = store;
     this.StoreLock = storeLock;
     this.TimeoutHelper = new TimeoutHelper(timeout);
     this.OnCompleting += SqlWorkflowInstanceStoreAsyncResult.finallyCallback;
     this.maximumRetries = maximumRetries;
 }
コード例 #6
0
        internal TransactionWaitAsyncResult(System.Transactions.Transaction transaction, System.ServiceModel.Activities.Dispatcher.PersistenceContext persistenceContext, TimeSpan timeout, AsyncCallback callback, object state) : base(callback, state)
        {
            bool flag = false;
            TransactionException exception = null;

            this.PersistenceContext = persistenceContext;
            this.thisLock           = new object();
            if (null != transaction)
            {
                this.dependentTransaction = transaction.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
            }
            else
            {
                this.dependentTransaction = null;
            }
            lock (this.ThisLock)
            {
                if (persistenceContext.QueueForTransactionLock(transaction, this))
                {
                    if (null != transaction)
                    {
                        this.dependentTransaction.Complete();
                        exception = this.CreateVolatileEnlistment(transaction);
                    }
                    flag = true;
                }
                else if (timeout != TimeSpan.MaxValue)
                {
                    this.timer = new IOThreadTimer(TimeoutCallbackAction, this, true);
                    this.timer.Set(timeout);
                }
            }
            if (flag)
            {
                base.Complete(true, exception);
            }
        }
コード例 #7
0
ファイル: TransactionScope.cs プロジェクト: geoffkizer/corefx
        // 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;
            }
        }
コード例 #8
0
ファイル: ThreadSql.cs プロジェクト: WrongDog/MyTest
 /// <summary>
 /// Indicate that sql is transaction if trans parameter is not null
 /// </summary>
 /// <param name="trans"></param>
 public void AddTransaction(Transaction trans)
 {
     if (trans != null)
         DependentTransaction = trans.DependentClone(DependentCloneOption.BlockCommitUntilComplete);
 }
        private void SetCurrent(Transaction newCurrent)
        {
            if (((this.dependentTransaction == null) && (this.committableTransaction == null)) && (newCurrent != null))
            {
                this.dependentTransaction = newCurrent.DependentClone(DependentCloneOption.RollbackIfNotComplete);
            }
            switch (this.interopOption)
            {
                case EnterpriseServicesInteropOption.None:
                    this.threadContextData.CurrentTransaction = newCurrent;
                    return;

                case EnterpriseServicesInteropOption.Automatic:
                    Transaction.VerifyEnterpriseServicesOk();
                    if (!Transaction.UseServiceDomainForCurrent())
                    {
                        this.threadContextData.CurrentTransaction = newCurrent;
                        return;
                    }
                    this.PushServiceDomain(newCurrent);
                    return;

                case EnterpriseServicesInteropOption.Full:
                    Transaction.VerifyEnterpriseServicesOk();
                    this.PushServiceDomain(newCurrent);
                    return;
            }
        }