PreparingEnlistment Klas

Definitie

Vereenvoudigt de communicatie tussen een ingeschreven transactiedeelnemer en de transactiemanager tijdens de voorbereidingsfase van de transactie.

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

Voorbeelden

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

Opmerkingen

Tijdens de eerste (voorbereidingsfase) van de transactie geeft de transactiebeheerder dit type door aan de resourcemanager door de Prepare methode aan te roepen om de stem van een resource op de transactie te verkrijgen. Afhankelijk van of het stemmen is om door te voeren of terug te draaien, moet uw implementatie van resourcemanager de Prepared of ForceRollback methoden van dit type aanroepen.

Resource Manager kan de Done methode ook op elk gewenst moment aanroepen voordat deze de Prepared methode heeft aangeroepen. Door dit te doen, is de opname een alleen-lezen stem, wat betekent dat het stemmen doorvoert op de transactie, maar niet het uiteindelijke resultaat hoeft te ontvangen.

Duurzame resourcemanagers kunnen de informatie ophalen die nodig is voor de transactiebeheerder voor opnieuw in de lijst van de RecoveryInformation() eigenschap. Zie Herstel uitvoeren voor meer informatie over herstel.

Methoden

Name Description
Done()

Geeft aan dat de transactiedeelnemer het werk heeft voltooid.

(Overgenomen van Enlistment)
Equals(Object)

Bepaalt of het opgegeven object gelijk is aan het huidige object.

(Overgenomen van Object)
ForceRollback()

Geeft aan dat de transactie moet worden teruggedraaid.

ForceRollback(Exception)

Geeft aan dat de transactie moet worden teruggedraaid.

GetHashCode()

Fungeert als de standaardhashfunctie.

(Overgenomen van Object)
GetType()

Hiermee haalt u de Type huidige instantie op.

(Overgenomen van Object)
MemberwiseClone()

Hiermee maakt u een ondiepe kopie van de huidige Object.

(Overgenomen van Object)
Prepared()

Geeft aan dat de transactie kan worden doorgevoerd.

RecoveryInformation()

Hiermee haalt u de herstelgegevens van een opname op.

ToString()

Retourneert een tekenreeks die het huidige object vertegenwoordigt.

(Overgenomen van Object)

Van toepassing op

Veiligheid thread

Dit type is thread veilig.

Zie ook