PreparingEnlistment Třída

Definice

Usnadňuje komunikaci mezi účastníkem zařaděné transakce a správcem transakcí během fáze Příprava transakce.

public ref class PreparingEnlistment : System::Transactions::Enlistment
public class PreparingEnlistment : System.Transactions.Enlistment
type PreparingEnlistment = class
    inherit Enlistment
Public Class PreparingEnlistment
Inherits Enlistment
Dědičnost
PreparingEnlistment

Příklady

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

Poznámky

Během počáteční fáze (příprava) transakce správce transakce předá tento typ správci prostředků voláním Prepare metody získat hlasování o prostředku transakce. V závislosti na tom, jestli hlasuje k potvrzení nebo vrácení zpět, by vaše implementace správce prostředků měla volat Prepared nebo ForceRollback metody tohoto typu.

Správce prostředků může metodu Done volat kdykoli předtím, než zavolá metodu Prepared . Tímto způsobem je zařazení přetypování hlasování jen pro čtení, což znamená, že hlasuje potvrzení o transakci, ale nemusí přijímat konečný výsledek.

Správci trvalých prostředků můžou načíst informace, které správce transakcí potřebuje k opětovnému zařazení z RecoveryInformation vlastnosti. Další informace o obnovení naleznete v tématu Provádění obnovení.

Metody

Done()

Označuje, že účastník transakce dokončil svou práci.

(Zděděno od Enlistment)
Equals(Object)

Určí, zda se zadaný objekt rovná aktuálnímu objektu.

(Zděděno od Object)
ForceRollback()

Označuje, že transakce by se měla vrátit zpět.

ForceRollback(Exception)

Označuje, že transakce by se měla vrátit zpět.

GetHashCode()

Slouží jako výchozí funkce hash.

(Zděděno od Object)
GetType()

Type Získá aktuální instanci.

(Zděděno od Object)
MemberwiseClone()

Vytvoří použádnou kopii aktuálního souboru Object.

(Zděděno od Object)
Prepared()

Označuje, že transakce může být potvrzena.

RecoveryInformation()

Získá informace o obnovení zařazení.

ToString()

Vrátí řetězec, který představuje aktuální objekt.

(Zděděno od Object)

Platí pro

Bezpečný přístup z více vláken

Tento typ je bezpečný pro přístup z více vláken.

Viz také