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(
TraceSourceType.TraceSourceLtm,
SR.UnexpectedTimerFailure,
null
);
}
_lastTimerTime = DateTime.UtcNow.Ticks;
_timerEnabled = true;
}
}
txNew.CreationTime = CurrentTime;
AddIter(txNew);
}
finally
{
_rwLock.ExitReadLock();
}
return readerIndex;
}