Enlistment クラス
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
トランザクションの最終フェーズ中に、参加しているトランザクション参加者とトランザクション マネージャー間の通信を容易にします。
public ref class Enlistment
public class Enlistment
type Enlistment = class
Public Class Enlistment
- 継承
-
Enlistment
- 派生
例
次の例は、 IEnlistmentNotification インターフェイスの実装と、 Done メソッドを呼び出すタイミングを示しています。
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
注釈
Transaction オブジェクトのEnlistVolatileメソッドとEnlistDurable メソッドを呼び出してトランザクションに参加させると、参加要素を記述するこのオブジェクトが返されます。
トランザクション コミットの最終フェーズ中に、トランザクション マネージャーは、トランザクションに参加している IEnlistmentNotification インターフェイスを実装するリソース マネージャーにこのオブジェクトを渡します。 具体的には、トランザクション マネージャーは、トランザクションのコミットまたはロールバックを決定したかどうかに応じて、参加者の Commit または Rollback メソッドを呼び出します。 参加者は、このオブジェクトの Done メソッドを呼び出して、処理が完了したことをトランザクション マネージャーに知らせる必要があります。
参加リストは、準備フェーズでPreparedを呼び出す前に、いつでも Done メソッドを呼び出すことができます。 そうすることで、参加は読み取り専用の投票を行います。つまり、トランザクションに対するコミットに投票しますが、最終的な結果を受け取る必要はありません。 Doneメソッドが呼び出されると、参加している参加者はトランザクション マネージャーからそれ以上の通知を受け取らなくなります。
メソッド
| 名前 | 説明 |
|---|---|
| Done() |
トランザクション参加者が作業を完了したことを示します。 |
| Equals(Object) |
指定したオブジェクトが現在のオブジェクトと等しいかどうかを判断します。 (継承元 Object) |
| GetHashCode() |
既定のハッシュ関数として機能します。 (継承元 Object) |
| GetType() |
現在のインスタンスの Type を取得します。 (継承元 Object) |
| MemberwiseClone() |
現在の Objectの簡易コピーを作成します。 (継承元 Object) |
| ToString() |
現在のオブジェクトを表す文字列を返します。 (継承元 Object) |
適用対象
スレッド セーフ
この型はスレッド セーフです。