PreparingEnlistment Klasa

Definicja

Ułatwia komunikację między uczestnikiem transakcji na liście a menedżerem transakcji w fazie przygotowywania transakcji.

public ref class PreparingEnlistment : System::Transactions::Enlistment
public class PreparingEnlistment : System.Transactions.Enlistment
type PreparingEnlistment = class
    inherit Enlistment
Public Class PreparingEnlistment
Inherits Enlistment
Dziedziczenie
PreparingEnlistment

Przykłady

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

Uwagi

W początkowej fazie (przygotowania) transakcji menedżer transakcji przekazuje ten typ do menedżera zasobów, wywołując Prepare metodę w celu uzyskania głosowania zasobu w sprawie transakcji. W zależności od tego, czy głosuje na zatwierdzenie, czy wycofać, implementacja menedżera zasobów powinna wywołać Prepared metody lub ForceRollback tego typu.

Menedżer zasobów może również wywołać metodę Done w dowolnym momencie, zanim wywoła metodę Prepared . W ten sposób rejestracja rzutuje głos tylko do odczytu, co oznacza, że głosuje za zatwierdzeniem transakcji, ale nie musi otrzymywać końcowego wyniku.

Menedżerowie zasobów trwałych mogą pobierać informacje potrzebne przez menedżera transakcji do ponownego RecoveryInformation rejestrowania z właściwości. Aby uzyskać więcej informacji na temat odzyskiwania, zobacz Wykonywanie odzyskiwania.

Metody

Done()

Wskazuje, że uczestnik transakcji wykonał swoją pracę.

(Odziedziczone po Enlistment)
Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
ForceRollback()

Wskazuje, że transakcja powinna zostać wycofana.

ForceRollback(Exception)

Wskazuje, że transakcja powinna zostać wycofana.

GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
Prepared()

Wskazuje, że transakcja może zostać zatwierdzona.

RecoveryInformation()

Pobiera informacje o odzyskiwaniu rejestracji.

ToString()

Zwraca ciąg reprezentujący bieżący obiekt.

(Odziedziczone po Object)

Dotyczy

Bezpieczeństwo wątkowe

Ten typ jest bezpieczny wątkowo.

Zobacz też