EnlistVolatile() public method

public EnlistVolatile ( IEnlistmentNotification enlistmentNotification, EnlistmentOptions enlistmentOptions ) : Enlistment
enlistmentNotification IEnlistmentNotification
enlistmentOptions EnlistmentOptions
return Enlistment
    internal SQLiteEnlistment(SQLiteConnection cnn, Transaction scope)
    {
      _transaction = cnn.BeginTransaction();
      _scope = scope;

      _scope.EnlistVolatile(this, System.Transactions.EnlistmentOptions.None);
    }
Esempio n. 2
0
        private TransactionException CreateVolatileEnlistment(System.Transactions.Transaction transactionToEnlist)
        {
            TransactionException         exception  = null;
            PersistenceContextEnlistment enlistment = null;
            int hashCode = transactionToEnlist.GetHashCode();

            lock (System.ServiceModel.Activities.Dispatcher.PersistenceContext.Enlistments)
            {
                try
                {
                    if (!System.ServiceModel.Activities.Dispatcher.PersistenceContext.Enlistments.TryGetValue(hashCode, out enlistment))
                    {
                        enlistment = new PersistenceContextEnlistment(this.PersistenceContext, transactionToEnlist);
                        transactionToEnlist.EnlistVolatile(enlistment, EnlistmentOptions.None);
                        System.ServiceModel.Activities.Dispatcher.PersistenceContext.Enlistments.Add(hashCode, enlistment);
                        return(exception);
                    }
                    enlistment.AddToEnlistment(this.PersistenceContext);
                    return(exception);
                }
                catch (TransactionException exception2)
                {
                    exception = exception2;
                    this.PersistenceContext.ScheduleNextTransactionWaiter();
                }
            }
            return(exception);
        }
Esempio n. 3
0
        public DeveelDbEnlistment(DeveelDbConnection connection, Transaction scope)
        {
            transaction = connection.BeginTransaction();

            Scope = scope;
            Scope.EnlistVolatile(this, EnlistmentOptions.None);
        }
		public FbEnlistmentNotification(FbConnectionInternal connection, Transaction systemTransaction)
		{
			_connection = connection;
			_transaction = connection.BeginTransaction(systemTransaction.IsolationLevel);
			_systemTransaction = systemTransaction;

			_systemTransaction.EnlistVolatile(this, System.Transactions.EnlistmentOptions.None);
		}
Esempio n. 5
0
 private bool Enlist(Db4oEnlist enlist)
 {
     System.Transactions.Transaction currentTx = System.Transactions.Transaction.Current;
     if (currentTx != null)
     {
         currentTx.EnlistVolatile(enlist, EnlistmentOptions.None);
         return(true);
     }
     return(false);
 }
Esempio n. 6
0
    internal SQLiteEnlistment(
        SQLiteConnection cnn,
        Transaction scope,
        System.Data.IsolationLevel defaultIsolationLevel,
        bool throwOnUnavailable,
        bool throwOnUnsupported
        )
    {
      _transaction = cnn.BeginTransaction(GetSystemDataIsolationLevel(
          cnn, scope, defaultIsolationLevel, throwOnUnavailable,
          throwOnUnsupported));

      _scope = scope;

      _scope.EnlistVolatile(this, System.Transactions.EnlistmentOptions.None);
    }
            public void SetInteriorTransaction(Transaction interiorTransaction, bool needsCommit)
            {
                Fx.Assert(!this.context.IsHostTransaction, "SetInteriorTransaction called for a host transaction.");

                if (this.waitForTransaction != null)
                {
                    throw Fx.Exception.AsError(new InvalidOperationException(SRCore.ExecuteMustBeNested));
                }

                bool success = false;
                try
                {
                    this.waitForTransaction = new AsyncWaitHandle(EventResetMode.ManualReset);
                    interiorTransaction.EnlistVolatile(this, EnlistmentOptions.None);
                    success = true;
                }
                finally
                {
                    if (!success)
                    {
                        if (this.waitForTransaction != null)
                        {
                            this.waitForTransaction.Set();
                        }
                    }
                    else if (needsCommit)
                    {
                        this.transactionToCommit = (CommittableTransaction)interiorTransaction;
                    }
                }
            }
 void RegisterForTransactionNotification(Transaction transaction)
 {
     if (Transaction.Current != null)
     {
         ReceiveContextEnlistmentNotification notification = new ReceiveContextEnlistmentNotification(this);
         transaction.EnlistVolatile(notification, EnlistmentOptions.None);
         Interlocked.Increment(ref this.ambientTransactionCount);
     }
 }
 public TxEnlistment(Transaction tx)
 {
     tx.EnlistVolatile(this, EnlistmentOptions.None);
 }
        TransactionException CreateVolatileEnlistment(Transaction transactionToEnlist)
        {
            TransactionException result = null;
            PersistenceContextEnlistment enlistment = null;
            int key = transactionToEnlist.GetHashCode();
            lock (PersistenceContext.Enlistments)
            {
                try
                {
                    if (!PersistenceContext.Enlistments.TryGetValue(key, out enlistment))
                    {
                        enlistment = new PersistenceContextEnlistment(this.PersistenceContext, transactionToEnlist);
                        transactionToEnlist.EnlistVolatile(enlistment, EnlistmentOptions.None);
                        // We don't save of the Enlistment object returned from EnlistVolatile. We don't need
                        // it here. When our PersistenceContextEnlistment object gets notified on Prepare,
                        // Commit, Rollback, or InDoubt, it is provided with the Enlistment object.
                        PersistenceContext.Enlistments.Add(key, enlistment);
                    }
                    else
                    {
                        enlistment.AddToEnlistment(this.PersistenceContext);
                    }
                }
                catch (TransactionException txException)
                {
                    result = txException;

                    // We own the lock but failed to create enlistment.  Manually wake up the next waiter.
                    // We only handle TransactionException, in case of other exception that failed to create enlistment,
                    // It will fallback to Timeout.  This is safe to avoid multiple waiters owning same lock.
                    this.PersistenceContext.ScheduleNextTransactionWaiter();
                }
            }
            return result;
        }
 public void SetInteriorTransaction(Transaction interiorTransaction, bool needsCommit)
 {
     if (this.waitForTransaction != null)
     {
         throw Fx.Exception.AsError(new InvalidOperationException(SRCore.ExecuteMustBeNested));
     }
     bool flag = false;
     try
     {
         this.waitForTransaction = new AsyncWaitHandle(EventResetMode.ManualReset);
         interiorTransaction.EnlistVolatile((ISinglePhaseNotification) this, EnlistmentOptions.None);
         flag = true;
     }
     finally
     {
         if (!flag)
         {
             if (this.waitForTransaction != null)
             {
                 this.waitForTransaction.Set();
             }
         }
         else if (needsCommit)
         {
             this.transactionToCommit = (CommittableTransaction) interiorTransaction;
         }
     }
 }
 public EventResourceManager(EventEmitter eventEmitter, Transaction transaction)
 {
     this.eventEmitter = eventEmitter;
     transaction.EnlistVolatile(this, EnlistmentOptions.None);
     changes = new List<RaisedEvent>();
 }
 internal VoterBallot(ITransactionVoterNotifyAsync2 notification, Transaction transaction)
 {
     this.transaction = transaction;
     this.notification = notification;
     this.enlistment = transaction.EnlistVolatile(this, EnlistmentOptions.None);
 }