共用方式為


TransactionVote 列舉

定義

指定允許用於交易結果表決的值。

public enum class TransactionVote
[System.Runtime.InteropServices.ComVisible(false)]
[System.Serializable]
public enum TransactionVote
[<System.Runtime.InteropServices.ComVisible(false)>]
[<System.Serializable>]
type TransactionVote = 
Public Enum TransactionVote
繼承
TransactionVote
屬性

欄位

Abort 1

中止目前交易。

Commit 0

認可目前交易。

範例

下列程式代碼範例示範此列舉的使用。


[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

備註

這項列舉供 ContextUtil 類別使用。

適用於