/// <summary> /// This method removes any event notifiers that have timed out. /// </summary> private void RemoveTimedOutTransactionEventNotifiers( ) { var notifiersToRemove = new List <string>( ); lock ( _syncRoot ) { foreach (var kvp in _transactionEventNotifiers) { string id = kvp.Key; TransactionEventNotifier eventNotifier = kvp.Value; if (eventNotifier.HasTimedOut(_timeOutIntervalSeconds)) { eventNotifier.Enabled = false; notifiersToRemove.Add(id); } } } foreach (string id in notifiersToRemove) { Rollback(id); lock ( _syncRoot ) { _transactionEventNotifiers.Remove(id); } } }
/// <summary> /// Enlists the specified cache entry as being modified during a transaction. /// </summary> /// <param name="transaction">The current transaction</param> public void EnlistTransaction(Transaction transaction) { lock ( _syncRoot ) { TransactionEventNotifier eventNotifier; if (transaction != null && !_transactionEventNotifiers.TryGetValue(transaction.TransactionInformation.LocalIdentifier, out eventNotifier)) { eventNotifier = new TransactionEventNotifier(this, transaction); _transactionEventNotifiers[transaction.TransactionInformation.LocalIdentifier] = eventNotifier; transaction.EnlistVolatile(eventNotifier, EnlistmentOptions.None); } } RemoveTimedOutTransactionEventNotifiers( ); }