Язык

ContextUtil.MyTransactionVote Свойство

Определение

Возвращает или задает consistent бит в контексте COM+.

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 либо CommitAbort.

Исключения

Нет доступных контекстов 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

Комментарии

Если MyTransactionVote задано значениеCommit, то для фиксации транзакции задается consistent бит COM+, а для фиксации транзакции голосует контекст COM+true. Если MyTransactionVote задано значение Abort, consistent то бит задается false и контекст COM+ голосует за прерывание транзакции. Значение по умолчанию бита consistenttrue.

Бит consistent отправляет голос, чтобы зафиксировать или прервать транзакцию, в которой она выполняется, и done бит завершает голосование. COM+ проверяет consistent бит, если done бит установлен true в возвращаемом вызове метода или при деактивации объекта. Хотя бит объекта consistent может многократно изменяться в каждом вызове метода, только последние числа изменений.

Применяется к