internal static Transaction FindPromotedTransaction( Guid transactionIdentifier ) { Hashtable promotedTransactionTable = PromotedTransactionTable; WeakReference weakRef = (WeakReference)promotedTransactionTable[transactionIdentifier]; if (null != weakRef) { Transaction tx = weakRef.Target as Transaction; if (null != tx) { return(tx.InternalClone()); } else // an old, moldy weak reference. Let's get rid of it. { lock ( promotedTransactionTable ) { promotedTransactionTable.Remove(transactionIdentifier); } } } return(null); }
internal static Transaction FindOrCreatePromotedTransaction(Guid transactionIdentifier, OletxTransaction oletx) { Transaction target = null; Hashtable promotedTransactionTable = PromotedTransactionTable; lock (promotedTransactionTable) { WeakReference reference = (WeakReference)promotedTransactionTable[transactionIdentifier]; if (reference != null) { target = reference.Target as Transaction; if (null != target) { oletx.Dispose(); return(target.InternalClone()); } lock (promotedTransactionTable) { promotedTransactionTable.Remove(transactionIdentifier); } } target = new Transaction(oletx) { internalTransaction = { finalizedObject = new FinalizedObject(target.internalTransaction, oletx.Identifier) } }; reference = new WeakReference(target, false); promotedTransactionTable[oletx.Identifier] = reference; } oletx.savedLtmPromotedTransaction = target; FireDistributedTransactionStarted(target); return(target); }
// Fire completion to anyone registered for outcome internal void FireCompletion() { TransactionCompletedEventHandler?eventHandlers = _transactionCompletedDelegate; if (eventHandlers != null) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = _outcomeSource.InternalClone(); eventHandlers(args._transaction, args); } }
internal static void FireDistributedTransactionStarted(Transaction transaction) { TransactionStartedEventHandler?localStartedEventHandler = null; lock (ClassSyncObject) { localStartedEventHandler = s_distributedTransactionStartedDelegate; } if (null != localStartedEventHandler) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = transaction.InternalClone(); localStartedEventHandler(args._transaction, args); } }
internal static void FireDistributedTransactionStarted(Transaction transaction) { TransactionStartedEventHandler distributedTransactionStartedDelegate = null; lock (ClassSyncObject) { distributedTransactionStartedDelegate = TransactionManager.distributedTransactionStartedDelegate; } if (distributedTransactionStartedDelegate != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = transaction.InternalClone() }; distributedTransactionStartedDelegate(e.transaction, e); } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock ( PromotedTransactionTable ) { foreach (DictionaryEntry entry in PromotedTransactionTable) { WeakReference weakRef = (WeakReference)entry.Value; Transaction tx = (Transaction)weakRef.Target; if (tx != null) { TransactionEventArgs args = new TransactionEventArgs(); args.transaction = tx.InternalClone(); eventHandler(args.transaction, args); } } } }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock (PromotedTransactionTable) { foreach (DictionaryEntry entry in PromotedTransactionTable) { WeakReference reference = (WeakReference)entry.Value; Transaction target = (Transaction)reference.Target; if (target != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = target.InternalClone() }; eventHandler(e.transaction, e); } } } }
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); }
internal static void ProcessExistingTransactions(TransactionStartedEventHandler eventHandler) { lock (PromotedTransactionTable) { // Manual use of IDictionaryEnumerator instead of foreach to avoid DictionaryEntry box allocations. IDictionaryEnumerator e = PromotedTransactionTable.GetEnumerator(); while (e.MoveNext()) { WeakReference weakRef = (WeakReference)e.Value; Transaction tx = (Transaction)weakRef.Target; if (tx != null) { TransactionEventArgs args = new TransactionEventArgs(); args._transaction = tx.InternalClone(); eventHandler(args._transaction, args); } } } }
internal static Transaction FindPromotedTransaction(Guid transactionIdentifier) { Hashtable promotedTransactionTable = PromotedTransactionTable; WeakReference reference = (WeakReference)promotedTransactionTable[transactionIdentifier]; if (reference != null) { Transaction target = reference.Target as Transaction; if (null != target) { return(target.InternalClone()); } lock (promotedTransactionTable) { promotedTransactionTable.Remove(transactionIdentifier); } } return(null); }
internal static void FireDistributedTransactionStarted( Transaction transaction ) { TransactionStartedEventHandler localStartedEventHandler = null; lock ( ClassSyncObject ) { localStartedEventHandler = TransactionManager.distributedTransactionStartedDelegate; } if ( null != localStartedEventHandler ) { TransactionEventArgs args = new TransactionEventArgs(); args.transaction = transaction.InternalClone(); localStartedEventHandler(args.transaction, args); } }
internal static void FireDistributedTransactionStarted(Transaction transaction) { TransactionStartedEventHandler distributedTransactionStartedDelegate = null; lock (ClassSyncObject) { distributedTransactionStartedDelegate = TransactionManager.distributedTransactionStartedDelegate; } if (distributedTransactionStartedDelegate != null) { TransactionEventArgs e = new TransactionEventArgs { transaction = transaction.InternalClone() }; distributedTransactionStartedDelegate(e.transaction, e); } }