Enlistment 클래스

정의

트랜잭션의 마지막 단계에서 참여한 트랜잭션 참가 요소와 트랜잭션 관리자 간의 통신을 용이하게 합니다.

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

설명

트랜잭션에 참가자를 EnlistVolatile Transaction 등록하기 위해 개체의 메서드 및 EnlistDurable 메서드를 호출하면 인리스트먼트를 설명하는 이 개체를 반환합니다.

트랜잭션 커밋의 마지막 단계에서 트랜잭션 관리자는 이 개체를 트랜잭션에 참여시킨 인터페이스를 구현하는 IEnlistmentNotification 리소스 관리자에게 전달합니다. 특히 트랜잭션 관리자는 후자가 트랜잭션을 Commit 커밋하거나 Rollback 롤백하기로 결정했는지 여부에 따라 참가자의 메서드 또는 메서드를 호출합니다. 참가자는 이 개체의 Done 메서드를 호출하여 트랜잭션 관리자가 작업을 완료했음을 알려야 합니다.

인리스트먼트는 준비 단계에서 호출하기 전에 언제든지 메서드를 호출 Done Prepared 할 수 있습니다. 이렇게 함으로써 인리스트먼트는 읽기 전용 투표를 캐스팅합니다. 즉, 트랜잭션에 대한 커밋을 투표하지만 최종 결과를 받을 필요는 없습니다. 메서드가 Done 호출된 후에는 참가한 참가자가 트랜잭션 관리자로부터 더 이상 알림을 받지 못합니다.

메서드

Done()

트랜잭션 참가 요소가 작업을 완료했음을 나타냅니다.

Equals(Object)

지정된 개체가 현재 개체와 같은지 확인합니다.

(다음에서 상속됨 Object)
GetHashCode()

기본 해시 함수로 작동합니다.

(다음에서 상속됨 Object)
GetType()

현재 인스턴스의 Type을 가져옵니다.

(다음에서 상속됨 Object)
MemberwiseClone()

현재 Object의 단순 복사본을 만듭니다.

(다음에서 상속됨 Object)
ToString()

현재 개체를 나타내는 문자열을 반환합니다.

(다음에서 상속됨 Object)

적용 대상

스레드 보안

이 형식은 스레드로부터 안전합니다.

추가 정보