Rediger

Del via


ReceiveContext.Abandon Method

Definition

Causes the state machine to transition to the abandoned state.

Overloads

Abandon(TimeSpan)

Causes the state machine to transition to the abandoned state with the specified timeout value.

Abandon(Exception, TimeSpan)

Causes the state machine to transition to the abandoned state with the specified exception and timeout value.

Remarks

Abandon may stop responding when there is an ambient transaction and Complete is called and afterwards the transaction is rolled back. If Abandon is called prior to the transaction rollback completing, a race condition will exist, causing the call to Abandon to stop responding. This can be illustrated by the following pseudo-code example

using (TransactionScope ts = new TransactionScope())   
{  
   try  
   {  
       rc.Complete();  
      ...  
   }  
   Catch (Exception)   
   {  
      rc.Abandon()  
   }  
}  

This is not the recommended pattern for working with ReceiveContext. Instead the try/catch block should be placed outside of the transaction scope.

Abandon(TimeSpan)

Causes the state machine to transition to the abandoned state with the specified timeout value.

public:
 virtual void Abandon(TimeSpan timeout);
public virtual void Abandon (TimeSpan timeout);
abstract member Abandon : TimeSpan -> unit
override this.Abandon : TimeSpan -> unit
Public Overridable Sub Abandon (timeout As TimeSpan)

Parameters

timeout
TimeSpan

The timeout for the abandon operation to complete.

Applies to

Abandon(Exception, TimeSpan)

Causes the state machine to transition to the abandoned state with the specified exception and timeout value.

public:
 virtual void Abandon(Exception ^ exception, TimeSpan timeout);
public virtual void Abandon (Exception exception, TimeSpan timeout);
abstract member Abandon : Exception * TimeSpan -> unit
override this.Abandon : Exception * TimeSpan -> unit
Public Overridable Sub Abandon (exception As Exception, timeout As TimeSpan)

Parameters

exception
Exception

The exception that causes the abandon operation.

timeout
TimeSpan

The timeout for the abandon operation to complete.

Applies to