ContextUtil.DeactivateOnReturn Eigenschap

Definitie

Hiermee haalt u de bit op of stelt u deze done in de COM+-context in.

public:
 static property bool DeactivateOnReturn { bool get(); void set(bool value); };
public static bool DeactivateOnReturn { get; set; }
static member DeactivateOnReturn : bool with get, set
Public Shared Property DeactivateOnReturn As Boolean

Waarde van eigenschap

true als het object moet worden gedeactiveerd wanneer de methode wordt geretourneerd; anders, false. De standaardwaarde is false.

Uitzonderingen

Er is geen COM+-context beschikbaar.

Voorbeelden

In het volgende codevoorbeeld ziet u hoe de DeactivateOnReturn eigenschap wordt gebruikt om ervoor te zorgen dat een ServicedComponent eigenschap wordt gedeactiveerd na een methodeaanroep.


[assembly:System::Reflection::AssemblyKeyFile("Transaction.snk")];
[Transaction]
public ref class TransactionalComponent: public ServicedComponent
{
public:
   void TransactionalMethod( String^ data )
   {
      ContextUtil::DeactivateOnReturn = true;
      ContextUtil::MyTransactionVote = TransactionVote::Abort;
      
      // do work with data
      ContextUtil::MyTransactionVote = TransactionVote::Commit;
   }

};
[Transaction]
public class TransactionalComponent : ServicedComponent
{

    public void TransactionalMethod (string data)
    {

      ContextUtil.DeactivateOnReturn = true;
      ContextUtil.MyTransactionVote = TransactionVote.Abort;

      // Do work with data. Return if any errors occur.

      // Vote to commit. If any errors occur, this code will not execute.
      ContextUtil.MyTransactionVote = TransactionVote.Commit;
    }
}
<Transaction()>  _
Public Class TransactionalComponent
    Inherits ServicedComponent
    
    
    Public Sub TransactionalMethod(ByVal data As String) 
        
        ContextUtil.DeactivateOnReturn = True
        ContextUtil.MyTransactionVote = TransactionVote.Abort
        
        ' Do work with data. Return if any errors occur.
        ' Vote to commit. If any errors occur, this code will not execute.
        ContextUtil.MyTransactionVote = TransactionVote.Commit
    
    End Sub
End Class

Opmerkingen

De COM+ done bit bepaalt hoe lang het object actief blijft na het voltooien van het werk en kan van invloed zijn op de duur van een transactie. Wanneer een methode-aanroep wordt geretourneerd, inspecteert COM+ de done bit. Als de done bit is true, wordt het object door COM+ gedeactiveerd. Als de done bit is false, wordt het object niet gedeactiveerd.

Van toepassing op