PreparingEnlistment Classe

Definição

Facilita a comunicação entre um participante da transação inscrita e o gerenciador de transação durante a fase de Preparação da transação.Facilitates communication between an enlisted transaction participant and the transaction manager during the Prepare phase of the transaction.

public ref class PreparingEnlistment : System::Transactions::Enlistment
public class PreparingEnlistment : System.Transactions.Enlistment
type PreparingEnlistment = class
    inherit Enlistment
Public Class PreparingEnlistment
Inherits Enlistment
Herança
PreparingEnlistment

Exemplos

class myEnlistmentClass : IEnlistmentNotification
{
    public void Prepare(PreparingEnlistment preparingEnlistment)
    {
        Console.WriteLine("Prepare notification received");

        //Perform transactional work

        //If work finished correctly, reply prepared
        preparingEnlistment.Prepared();

        // otherwise, do a ForceRollback
        preparingEnlistment.ForceRollback();
    }

    public void Commit(Enlistment enlistment)
    {
        Console.WriteLine("Commit notification received");

        //Do any work necessary when commit notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void Rollback(Enlistment enlistment)
    {
        Console.WriteLine("Rollback notification received");

        //Do any work necessary when rollback notification is received

        //Declare done on the enlistment
        enlistment.Done();
    }

    public void InDoubt(Enlistment enlistment)
    {
        Console.WriteLine("In doubt notification received");

        //Do any work necessary when indout notification is received
        
        //Declare done on the enlistment
        enlistment.Done();
    }
}
Public Class EnlistmentClass
    Implements IEnlistmentNotification

    Public Sub Prepare(ByVal myPreparingEnlistment As PreparingEnlistment) Implements System.Transactions.IEnlistmentNotification.Prepare
        Console.WriteLine("Prepare notification received")

        'Perform transactional work

        'If work finished correctly, reply with prepared
        myPreparingEnlistment.Prepared()
    End Sub

    Public Sub Commit(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.Commit
        Console.WriteLine("Commit notification received")

        'Do any work necessary when commit notification is received

        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub

    Public Sub Rollback(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.Rollback
        Console.WriteLine("Rollback notification received")

        'Do any work necessary when rollback notification is received

        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub

    Public Sub InDoubt(ByVal myEnlistment As Enlistment) Implements System.Transactions.IEnlistmentNotification.InDoubt
        Console.WriteLine("In doubt notification received")

        'Do any work necessary when indout notification is received

        'Declare done on the enlistment
        myEnlistment.Done()
    End Sub
End Class

Comentários

Durante a fase inicial (preparar) da transação, o Gerenciador de transações passa esse tipo para o Gerenciador de recursos chamando o Prepare método para obter o voto de um recurso na transação.During the initial (prepare) phase of the transaction, the transaction manager passes this type to the resource manager by calling the Prepare method to obtain a resource's vote on the transaction. Dependendo se os votos de serem confirmados ou revertidos, sua implementação do Gerenciador de recursos deve chamar os Prepared ForceRollback métodos ou desse tipo.Depending on whether it votes to commit or roll back, your implementation of the resource manager should call the Prepared or ForceRollback methods of this type.

O Gerenciador de recursos também pode chamar o Done método a qualquer momento antes de chamar o Prepared método.The resource manager can also call the Done method at anytime before it has called the Prepared method. Fazendo isso, a inscrição está convertendo um voto somente leitura, o que significa que os votos são confirmados na transação, mas não precisam receber o resultado final.By doing so, the enlistment is casting a read only vote, meaning that it votes commit on the transaction but does not need to receive the final outcome.

Os gerenciadores de recursos duráveis podem recuperar as informações necessárias ao Gerenciador de transações para reinscrição a partir da RecoveryInformation propriedade.Durable resource managers can retrieve the information that is be needed by the transaction manager for re-enlistment from the RecoveryInformation property. Para obter mais informações sobre recuperação, consulte executando a recuperação.For more information on recovery, see Performing Recovery.

Métodos

Done()

Indica que o participante da transação concluiu seu trabalho.Indicates that the transaction participant has completed its work.

(Herdado de Enlistment)
Equals(Object)

Determina se o objeto especificado é igual ao objeto atual.Determines whether the specified object is equal to the current object.

(Herdado de Object)
ForceRollback()

Indica que a transação deve ser revertida.Indicates that the transaction should be rolled back.

ForceRollback(Exception)

Indica que a transação deve ser revertida.Indicates that the transaction should be rolled back.

GetHashCode()

Serve como a função de hash padrão.Serves as the default hash function.

(Herdado de Object)
GetType()

Obtém o Type da instância atual.Gets the Type of the current instance.

(Herdado de Object)
MemberwiseClone()

Cria uma cópia superficial do Object atual.Creates a shallow copy of the current Object.

(Herdado de Object)
Prepared()

Indica que a transação pode ser confirmada.Indicates that the transaction can be committed.

RecoveryInformation()

Obtém as informações de recuperação de uma inscrição.Gets the recovery information of an enlistment.

ToString()

Retorna uma cadeia de caracteres que representa o objeto atual.Returns a string that represents the current object.

(Herdado de Object)

Aplica-se a

Acesso thread-safe

Este tipo é thread-safe.This type is thread safe.