次の方法で共有


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 ビットがtrueされている場合、COM+ はオブジェクトを非アクティブ化します。 done ビットがfalseされている場合、オブジェクトは非アクティブ化されません。

適用対象