共用方式為


PreparingEnlistment 類別

定義

在交易的準備階段,協助登記的交易參與者與交易管理員之間的通訊。

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

範例

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

備註

在初始 (準備交易的) 階段期間,交易管理員會呼叫 Prepare 方法來取得交易的資源投票,將此類型傳遞給資源管理員。 根據它是否投票認可或復原,資源管理員的實作應該呼叫 Prepared 此類型的 或 ForceRollback 方法。

資源管理員也可以在呼叫 方法之前 Prepared 隨時呼叫 Done 方法。 如此一來,登記會轉型唯讀投票,這表示它會在交易上投票認可,但不需要接收最終結果。

長期資源管理員可以擷取交易管理員從 屬性重新登記 RecoveryInformation 所需的資訊。 如需復原的詳細資訊,請參閱 執行復原

方法

Done()

指出交易參與者已完成其工作。

(繼承來源 Enlistment)
Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
ForceRollback()

表示應該復原交易。

ForceRollback(Exception)

表示應該復原交易。

GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
Prepared()

指出可以認可交易。

RecoveryInformation()

取得登記的復原資訊。

ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於

執行緒安全性

此型別具備執行緒安全。

另請參閱