ISinglePhaseNotification 介面

定義

描述一個資源物件,其支援參與交易的單一階段交易認可最佳化。Describes a resource object that supports single phase commit optimization to participate in a transaction.

public interface class ISinglePhaseNotification : System::Transactions::IEnlistmentNotification
public interface ISinglePhaseNotification : System.Transactions.IEnlistmentNotification
type ISinglePhaseNotification = interface
    interface IEnlistmentNotification
Public Interface ISinglePhaseNotification
Implements IEnlistmentNotification
實作

備註

您應該要注意的是,即使您的 resource manager 執行此介面來支援單一階段交易認可優化,也不保證它會接收單一階段認可。You should note that even when your resource manager implements this interface to support single phase commit optimization, it is not guaranteed that it receives a single phase commit. 交易管理員仍然可以改為傳送兩階段認可通知。The transaction manager can still send two phase commit notifications instead.

若要在交易中登記資源管理員做為參與者,請呼叫 EnlistVolatile 方法或 EnlistDurable 類別的方法 TransactionTo enlist your resource manager as a participant in a transaction, call the EnlistVolatile method or the EnlistDurable method of the Transaction class. 具體而言, EnlistmentOptions 參數應該等於, None 以確保執行單一階段認可。Specifically, the EnlistmentOptions parameter should equal to None to ensure that a single phase commit is performed. 如果錯誤地設定為 EnlistDuringPrepareRequired ,則不會進行單一階段認可。If it is mistakenly set to EnlistDuringPrepareRequired, no single phase commit occurs.

由於 ISinglePhaseNotification 介面衍生自 IEnlistmentNotification 介面,因此,資源管理員也必須針對兩階段認可通知,執行後者的所有方法。Since the ISinglePhaseNotification interface derives from the IEnlistmentNotification interface, the resource manager must also implement all the methods of the latter for two phase commit notifications. 交易管理員的選擇是要與此資源管理員一起使用兩階段認可還是單一階段認可優化。It is the transaction manager's choice as to whether two phase commit or the single phase commit optimization is used with this resource manager. 不過,執行此介面可讓資源管理員有機會在可用時利用優化功能。However, implementing this interface gives the resource manager the opportunity to take advantage of the optimization when it is available.

如果使用優化,而且交易管理員呼叫已 SinglePhaseCommit 登記資源的方法,則資源管理員應該使用類別的各種方法來回應此呼叫, SinglePhaseEnlistment 以通知交易管理員交易是否要認可或回復。If the optimization is used and the transaction manager calls the SinglePhaseCommit method of the enlisted resource, the resource manager should respond to this call by using various methods of the SinglePhaseEnlistment class to inform the transaction manager if the transaction is to be committed or rolled back.

方法

Commit(Enlistment)

告知登記的物件正在認可交易。Notifies an enlisted object that a transaction is being committed.

(繼承來源 IEnlistmentNotification)
InDoubt(Enlistment)

告知登記的物件交易的狀態不確定。Notifies an enlisted object that the status of a transaction is in doubt.

(繼承來源 IEnlistmentNotification)
Prepare(PreparingEnlistment)

告知登記的物件正在準備認可交易。Notifies an enlisted object that a transaction is being prepared for commitment.

(繼承來源 IEnlistmentNotification)
Rollback(Enlistment)

告知登記的物件正在復原 (中止) 交易。Notifies an enlisted object that a transaction is being rolled back (aborted).

(繼承來源 IEnlistmentNotification)
SinglePhaseCommit(SinglePhaseEnlistment)

表示資源管理員之單一階段交易認可最佳化的回呼實作。Represents the resource manager's implementation of the callback for the single phase commit optimization.

適用於

另請參閱