Share via


ContextUtil.DeactivateOnReturn プロパティ

定義

COM+ コンテキストの done ビットを取得または設定します。

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

プロパティ値

メソッドが返されるとこのオブジェクトが非アクティブになる場合は true。それ以外の場合は false。 既定値は、false です。

例外

使用できる COM+ コンテキストはありません。

次のコード例では、 プロパティを使用して、 DeactivateOnReturn がメソッド呼び出し後に非アクティブ化されることを確認 ServicedComponent します。


[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

注釈

COM+ done ビットは、オブジェクトが作業を完了した後もアクティブなままの期間を決定し、トランザクションの期間に影響を与える可能性があります。 メソッド呼び出しが返されると、COM+ はビットを検査します done 。 ビットが の done 場合、COM+ は trueオブジェクトを非アクティブ化します。 ビットが のdonefalse場合、オブジェクトは非アクティブ化されません。

適用対象