Share via


ContextUtil.MyTransactionVote プロパティ

定義

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

public:
 static property System::EnterpriseServices::TransactionVote MyTransactionVote { System::EnterpriseServices::TransactionVote get(); void set(System::EnterpriseServices::TransactionVote value); };
public static System.EnterpriseServices.TransactionVote MyTransactionVote { get; set; }
static member MyTransactionVote : System.EnterpriseServices.TransactionVote with get, set
Public Shared Property MyTransactionVote As TransactionVote

プロパティ値

TransactionVote である Commit または Abort のいずれか。

例外

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

次のコード例では、 プロパティを使用 MyTransactionVote してトランザクション 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

注釈

が にCommit設定されている場合MyTransactionVote、COM+ consistent ビットが にtrue設定され、COM+ コンテキストがトランザクションのコミットに投票します。 が にAbort設定されている場合MyTransactionVoteconsistentビットは にfalse設定され、COM+ コンテキストはトランザクションを中止するために投票します。 ビットの consistent 既定値は です true

ビットは consistent 、実行されるトランザクションをコミットまたは中止するために投票をキャストし、ビットによって done 投票が終了します。 COM+ は、consistentメソッド呼び出しでビットが にtrue設定されている場合done、またはオブジェクトが非アクティブ化されたときに、ビットを検査します。 オブジェクトの consistent ビットは各メソッド呼び出し内で繰り返し変更できますが、最後の変更のみがカウントされます。

適用対象