Enlistmentとは? わかりやすく解説

Enlistment クラス

メモ : このクラスは、.NET Framework version 2.0 で新しく追加されたものです。

トランザクションの最終フェーズにおいて、トランザクションに参加している参加要素とトランザクション マネージャの間の通信を容易にします。

名前空間: System.Transactions
アセンブリ: System.Transactions (system.transactions.dll 内)
構文構文

public class Enlistment
public ref class Enlistment
public class Enlistment
public class Enlistment
解説解説

トランザクションに参加要素を参加させるために Transaction オブジェクトの EnlistVolatile メソッドおよび EnlistDurable メソッドを呼び出すと、参加リストを示すこのオブジェクトが返されます。

トランザクションのコミットの最終フェーズで、トランザクション マネージャは、このオブジェクトをトランザクションに参加している IEnlistmentNotification インターフェイスを実装するリソース マネージャに渡します。特に、トランザクション マネージャは、リソース マネージャがトランザクションのコミットを決定しているか、またはロールバックの実行を決定しているかに基づいて、参加要素の Commit メソッドまたは Rollback メソッドを呼び出します。参加要素は、このオブジェクトの Done メソッドを呼び出して、トランザクション マネージャに作業の完了を通知する必要があります。

参加リストは、準備フェーズで Prepared を呼び出す前に、いつでも Done メソッドを呼び出すことができます。これにより、参加リストは読み取り専用の決定を行います。これは、トランザクションはコミットするが、最終結果を受け取る必要がないことを意味します。Done メソッドの呼び出し後、登録されている参加要素は、トランザクション マネージャからさらに通知を受け取ることはありません。

使用例使用例

IEnlistmentNotification インターフェイスの実装と、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
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();
    }
}
継承階層継承階層
System.Object
  System.Transactions.Enlistment
     System.Transactions.PreparingEnlistment
     System.Transactions.SinglePhaseEnlistment
スレッド セーフスレッド セーフ

この型は、マルチスレッド操作に対して安全です。

プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照

Enlistment メソッド


パブリック メソッドパブリック メソッド

プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Enlistment クラス
System.Transactions 名前空間
PreparingEnlistment
IEnlistmentNotification

その他の技術情報

トランザクションへの参加要素としてのリソースの登録

Enlistment メンバ

トランザクションの最終フェーズにおいて、トランザクションに参加している参加要素とトランザクション マネージャの間の通信を容易にします。

Enlistment データ型で公開されるメンバを以下の表に示します。


パブリック メソッドパブリック メソッド
プロテクト メソッドプロテクト メソッド
参照参照

関連項目

Enlistment クラス
System.Transactions 名前空間
PreparingEnlistment
IEnlistmentNotification

その他の技術情報

トランザクションへの参加要素としてのリソースの登録



英和和英テキスト翻訳

英語⇒日本語日本語⇒英語

辞書ショートカット

すべての辞書の索引

「Enlistment」の関連用語

Enlistmentのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



Enlistmentのページの著作権

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2026 Microsoft.All rights reserved.

©2026 GRAS Group, Inc.RSS