Bagikan melalui


PreparingEnlistment Kelas

Definisi

Memfasilitasi komunikasi antara peserta transaksi terdaftar dan manajer transaksi selama fase Persiapan transaksi.

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

Contoh

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

Keterangan

Selama fase awal (persiapan) transaksi, manajer transaksi meneruskan jenis ini ke manajer sumber daya dengan memanggil Prepare metode untuk mendapatkan suara sumber daya pada transaksi. Bergantung pada apakah memilih untuk menerapkan atau menggulung balik, implementasi manajer sumber daya Anda harus memanggil Prepared metode atau ForceRollback jenis ini.

Manajer sumber daya juga dapat memanggil Done metode kapan saja sebelum memanggil Prepared metode . Dengan demikian, pendaftaran memberikan suara baca saja, yang berarti bahwa itu memilih penerapan pada transaksi tetapi tidak perlu menerima hasil akhir.

Manajer sumber daya tahan lama dapat mengambil informasi yang diperlukan oleh manajer transaksi untuk pendaftaran ulang dari RecoveryInformation() properti. Untuk informasi selengkapnya tentang pemulihan, lihat Melakukan Pemulihan.

Metode

Nama Deskripsi
Done()

Menunjukkan bahwa peserta transaksi telah menyelesaikan pekerjaannya.

(Diperoleh dari Enlistment)
Equals(Object)

Menentukan apakah objek yang ditentukan sama dengan objek saat ini.

(Diperoleh dari Object)
ForceRollback()

Menunjukkan bahwa transaksi harus digulung balik.

ForceRollback(Exception)

Menunjukkan bahwa transaksi harus digulung balik.

GetHashCode()

Berfungsi sebagai fungsi hash default.

(Diperoleh dari Object)
GetType()

Mendapatkan Type instans saat ini.

(Diperoleh dari Object)
MemberwiseClone()

Membuat salinan dangkal dari Objectsaat ini.

(Diperoleh dari Object)
Prepared()

Menunjukkan bahwa transaksi dapat dilakukan.

RecoveryInformation()

Mendapatkan informasi pemulihan dari pendaftaran.

ToString()

Mengembalikan string yang mewakili objek saat ini.

(Diperoleh dari Object)

Berlaku untuk

Keamanan Thread

Jenis ini aman untuk utas.

Lihat juga