// Add a transaction to the table. Transactions are added to the end of the list in sorted order based on their // absolute timeout. internal int Add(InternalTransaction txNew) { // Tell the runtime that we are modifying global state. int readerIndex = 0; readerIndex = _rwLock.EnterReadLock(); try { // Start the timer if needed before checking the current time since the current // time can be more efficient with a running timer. if (txNew.AbsoluteTimeout != long.MaxValue) { if (!_timerEnabled) { if (!_timer.Change(_timerInterval, _timerInterval)) { throw TransactionException.CreateInvalidOperationException( SR.TraceSourceLtm, SR.UnexpectedTimerFailure, null ); } _lastTimerTime = DateTime.UtcNow.Ticks; _timerEnabled = true; } } txNew.CreationTime = CurrentTime; AddIter(txNew); } finally { _rwLock.ExitReadLock(); } return(readerIndex); }