Sdílet prostřednictvím


ContextUtil.DeactivateOnReturn Vlastnost

Definice

Získá nebo nastaví done bit v kontextu modelu COM +.

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

Hodnota vlastnosti

truepokud má být objekt deaktivován, když metoda vrátí; v opačném případě . false Výchozí formát je false.

Výjimky

Není k dispozici žádný kontext modelu COM+.

Příklady

Následující příklad kódu ukazuje použití DeactivateOnReturn vlastnosti k zajištění, že ServicedComponent je deaktivován po volání metody.


[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

Poznámky

Bit MODELU COM + done určuje, jak dlouho objekt zůstává aktivní po dokončení své práce a může ovlivnit dobu trvání transakce. Když volání metody vrátí, com + zkontroluje done bit. Pokud je truebit done , com + deaktivuje objekt. done Pokud je falsebit , objekt se neaktivuje.

Platí pro