예제 #1
0
        internal static Transaction FindOrCreatePromotedTransaction(
            Guid transactionIdentifier,
            Oletx.OletxTransaction oletx
            )
        {
            Transaction tx = null;
            Hashtable promotedTransactionTable = PromotedTransactionTable;
            lock (promotedTransactionTable)
            {
                WeakReference weakRef = (WeakReference) promotedTransactionTable[transactionIdentifier];
                if ( null != weakRef )
                {
                    tx = weakRef.Target as Transaction;
                    if ( null != tx )
                    {
                        // If we found a transaction then dispose the oletx
                        oletx.Dispose();
                        return tx.InternalClone();
                    }
                    else  // an old, moldy weak reference.  Let's get rid of it.
                    {
                        lock ( promotedTransactionTable )
                        {
                            promotedTransactionTable.Remove( transactionIdentifier );
                        }
                    }
                }

                tx = new Transaction( oletx );

                // Since we are adding this reference to the table create an object that will clean that
                // entry up.
                tx.internalTransaction.finalizedObject = new FinalizedObject( tx.internalTransaction, oletx.Identifier );

                weakRef = new WeakReference( tx, false );
                promotedTransactionTable[oletx.Identifier] = weakRef;
            }
            oletx.savedLtmPromotedTransaction = tx;

            TransactionManager.FireDistributedTransactionStarted( tx );

            return tx;
        }
예제 #2
0
 internal Transaction(
     Oletx.OletxTransaction oleTransaction
     )
 {
     this.isoLevel = oleTransaction.IsolationLevel;
     this.internalTransaction = new InternalTransaction(this, oleTransaction);
     this.cloneId = Interlocked.Increment(ref this.internalTransaction.cloneCount);
 }
        // Construct an internal transaction
        internal InternalTransaction( Transaction outcomeSource, Oletx.OletxTransaction distributedTx )
        {
            if ( !TransactionManager._platformValidated ) TransactionManager.ValidatePlatform();

            this.promotedTransaction = distributedTx;

            this.absoluteTimeout = long.MaxValue;

            // Store the initial creater as it will be the source of outcome events
            this.outcomeSource = outcomeSource;

            // Initialize the hash
            this.transactionHash = TransactionManager.TransactionTable.Add( this );

            // Start the transaction off as active
            TransactionState._TransactionStateNonCommittablePromoted.EnterState( this );
            
            // Until otherwise noted this transaction uses normal promotion.
            this.promoteState = TransactionState._TransactionStateNonCommittablePromoted;
        }