System.Transactions.TransactionScope.Timeout C# (CSharp) Method

Timeout() private method

private Timeout ( ) : void
return void
        private void Timeout()
        {
            if ((!_complete) && (null != _expectedCurrent))
            {
                TransactionsEtwProvider etwLog = TransactionsEtwProvider.Log;
                if (etwLog.IsEnabled())
                {
                    etwLog.TransactionScopeTimeout(_expectedCurrent.TransactionTraceId);
                }
                try
                {
                    _expectedCurrent.Rollback();
                }
                catch (ObjectDisposedException ex)
                {
                    // Tolerate the fact that the transaction has already been disposed.
                    if (etwLog.IsEnabled())
                    {
                        etwLog.ExceptionConsumed(TraceSourceType.TraceSourceBase, ex);
                    }
                }
                catch (TransactionException txEx)
                {
                    // Tolerate transaction exceptions
                    if (etwLog.IsEnabled())
                    {
                        etwLog.ExceptionConsumed(TraceSourceType.TraceSourceBase, txEx);
                    }
                }
            }
        }

Usage Example

        private static void TimerCallback(object state)
        {
            TransactionScope scope = state as TransactionScope;

            if (scope == null)
            {
                if (DiagnosticTrace.Critical)
                {
                    InternalErrorTraceRecord.Trace(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("TransactionScopeTimerObjectInvalid"));
                }
                throw TransactionException.Create(System.Transactions.SR.GetString("TraceSourceBase"), System.Transactions.SR.GetString("InternalError") + System.Transactions.SR.GetString("TransactionScopeTimerObjectInvalid"), null);
            }
            scope.Timeout();
        }
All Usage Examples Of System.Transactions.TransactionScope::Timeout