ContextUtil.MyTransactionVote Propriedade

Definição

Obtém ou define o bit consistent no contexto COM+.Gets or sets the consistent bit in the COM+ context.

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; }
member this.MyTransactionVote : System.EnterpriseServices.TransactionVote with get, set
Public Shared Property MyTransactionVote As TransactionVote

Valor da propriedade

TransactionVote

Um dos TransactionVote valores, Commit ou Abort .One of the TransactionVote values, either Commit or Abort.

Exceções

Não há contextos de COM+ disponíveis.There is no COM+ context available.

Exemplos

O exemplo de código a seguir demonstra como usar MyTransactionVote a propriedade para criar uma transacional ServicedComponent .The following code example demonstrates how to use MyTransactionVote property to create a transactional 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

Comentários

Quando MyTransactionVote é definido como Commit , o consistent bit com+ é definido como true e os votos de contexto com+ para confirmar a transação.When MyTransactionVote is set to Commit, the COM+ consistent bit is set to true and the COM+ context votes to commit the transaction. Se MyTransactionVote for definido como Abort , o consistent bit será definido como false e o contexto com+ votará para anular a transação.If MyTransactionVote is set to Abort, the consistent bit is set to false and the COM+ context votes to abort the transaction. O valor padrão do consistent bit é true .The default value of the consistent bit is true.

O consistent bit converte um voto para confirmar ou anular a transação na qual ele é executado e o done bit finaliza o voto.The consistent bit casts a vote to commit or abort the transaction in which it executes, and the done bit finalizes the vote. O COM+ inspeciona o consistent bit quando o done bit é definido como true em um retorno de chamada de método ou quando o objeto é desativado.COM+ inspects the consistent bit when the done bit is set to true on a method call return or when the object deactivates. Embora o bit de um objeto consistent possa ser alterado repetidamente dentro de cada chamada de método, somente as últimas contagens de alteração.Although an object's consistent bit can change repeatedly within each method call, only the last change counts.

Aplica-se a