DependentTransaction 클래스

정의

애플리케이션이 트랜잭션의 작업을 중지할 때까지 트랜잭션이 커밋되지 않도록 하는 트랜잭션 복제본에 대해 설명합니다.Describes a clone of a transaction providing guarantee that the transaction cannot be committed until the application comes to rest regarding work on the transaction. 이 클래스는 상속될 수 없습니다.This class cannot be inherited.

public ref class DependentTransaction sealed : System::Transactions::Transaction, System::Runtime::Serialization::ISerializable
public sealed class DependentTransaction : System.Transactions.Transaction, System.Runtime.Serialization.ISerializable
[System.Serializable]
public sealed class DependentTransaction : System.Transactions.Transaction, System.Runtime.Serialization.ISerializable
type DependentTransaction = class
    inherit Transaction
    interface ISerializable
Public NotInheritable Class DependentTransaction
Inherits Transaction
Implements ISerializable
상속
DependentTransaction
특성
구현

예제

다음 예제에서는 종속 트랜잭션을 만드는 방법을 보여 줍니다.The following example shows you how to create a dependent transaction.

static void Main(string[] args)
{
    try
    {
        using (TransactionScope scope = new TransactionScope())
        {
            // Perform transactional work here.

            //Queue work item
            ThreadPool.QueueUserWorkItem(new WaitCallback(WorkerThread), Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete));

            //Display transaction information
            Console.WriteLine("Transaction information:");
            Console.WriteLine("ID:             {0}", Transaction.Current.TransactionInformation.LocalIdentifier);
            Console.WriteLine("status:         {0}", Transaction.Current.TransactionInformation.Status);
            Console.WriteLine("isolationlevel: {0}", Transaction.Current.IsolationLevel);

            //Call Complete on the TransactionScope based on console input
            ConsoleKeyInfo c;
            while (true)
            {
                            Console.Write("Complete the transaction scope? [Y|N] ");
                c = Console.ReadKey();
                Console.WriteLine();

                if ((c.KeyChar == 'Y') || (c.KeyChar == 'y'))
                {
                    //Call complete on the scope
                    scope.Complete();
                    break;
                }
                else if ((c.KeyChar == 'N') || (c.KeyChar == 'n'))
                {
                    break;
                }
            }
        }
    }
    catch (System.Transactions.TransactionException ex)
    {
        Console.WriteLine(ex);
    }
    catch
    {
        Console.WriteLine("Cannot complete transaction");
        throw;
    }
}

private static void WorkerThread(object transaction)
{
    //Create a DependentTransaction from the object passed to the WorkerThread
    DependentTransaction dTx = (DependentTransaction)transaction;

    //Sleep for 1 second to force the worker thread to delay
    Thread.Sleep(1000);

    //Pass the DependentTransaction to the scope, so that work done in the scope becomes part of the transaction passed to the worker thread
    using (TransactionScope ts = new TransactionScope(dTx))
    {
        //Perform transactional work here.

        //Call complete on the transaction scope
        ts.Complete();
    }

    //Call complete on the dependent transaction
    dTx.Complete();
}
Public Shared Sub Main()
    Try
        Using scope As TransactionScope = New TransactionScope()

            'Perform transactional work here.

            'Queue work item
            ThreadPool.QueueUserWorkItem(AddressOf WorkerThread, Transaction.Current.DependentClone(DependentCloneOption.BlockCommitUntilComplete))

            'Display transaction information
            Console.WriteLine("Transaction information:")
            Console.WriteLine("ID:             {0}", Transaction.Current.TransactionInformation.LocalIdentifier)
            Console.WriteLine("status:         {0}", Transaction.Current.TransactionInformation.Status)
            Console.WriteLine("isolationlevel: {0}", Transaction.Current.IsolationLevel)

            'Call Complete on the TransactionScope based on console input
            Dim c As ConsoleKeyInfo
            While (True)

                Console.Write("Complete the transaction scope? [Y|N] ")
                c = Console.ReadKey()
                Console.WriteLine()
                If (c.KeyChar = "Y") Or (c.KeyChar = "y") Then
                    scope.Complete()
                    Exit While
                ElseIf ((c.KeyChar = "N") Or (c.KeyChar = "n")) Then
                    Exit While
                End If
            End While
        End Using

    Catch ex As TransactionException
        Console.WriteLine(ex)
    Catch
        Console.WriteLine("Cannot complete transaction")
        Throw
    End Try
End Sub

Public Shared Sub WorkerThread(ByVal myTransaction As Object)

    'Create a DependentTransaction from the object passed to the WorkerThread
    Dim dTx As DependentTransaction
    dTx = CType(myTransaction, DependentTransaction)

    'Sleep for 1 second to force the worker thread to delay
    Thread.Sleep(1000)

    'Pass the DependentTransaction to the scope, so that work done in the scope becomes part of the transaction passed to the worker thread
    Using ts As TransactionScope = New TransactionScope(dTx)
        'Perform transactional work here.

        'Call complete on the transaction scope
        ts.Complete()
    End Using

    'Call complete on the dependent transaction
    dTx.Complete()
End Sub

설명

DependentTransactionDependentClone 메서드를 사용 하 여 만든 Transaction 개체의 복제본입니다.The DependentTransaction is a clone of a Transaction object created using the DependentClone method. Rest 작업 (예: 작업자 스레드)에 트랜잭션 작업이 수행 되는 동안 트랜잭션이 커밋할 수 없습니다는 보장을 제공 하도록 애플리케이션을 허용 하도록 유일한 목적은 것입니다.Its sole purpose is to allow the application to come to rest and guarantee that the transaction cannot commit while work is still being performed on the transaction (for example, on a worker thread).

복제 된 트랜잭션 내에서 수행 된 작업이 최종적으로 완료 되 고 커밋될 준비가 되 면 Complete 메서드를 사용 하 여 트랜잭션을 작성자에 게 알릴 수 있습니다.When the work done within the cloned transaction is finally complete and ready to be committed, it can inform the creator of the transaction using the Complete method. 따라서 일관성과 데이터의 정확성을 유지할 수 있습니다.Thus you can preserve the consistency and correctness of data.

DependentCloneOption 열거형은 커밋에 대 한 동작을 결정 하는 데 사용 됩니다.The DependentCloneOption enumeration is used to determine the behavior on commit. 이 동작은 컨트롤 정지할 동시성 지원을 제공 하는 것은 물론 애플리케이션을 허용 합니다.This behavior control allows an application to come to rest, as well as provides concurrency support. 이 열거형을 사용 하는 방법에 대 한 자세한 내용은 DependentTransaction를 사용 하 여 동시성 관리를 참조 하세요.For more information on how this enumeration is used, see Managing Concurrency with DependentTransaction.

속성

IsolationLevel

트랜잭션의 격리 수준을 가져옵니다.Gets the isolation level of the transaction.

(다음에서 상속됨 Transaction)
PromoterType

트랜잭션을 승격할 때 확장 메서드에서 반환한 byte[]의 형식을 고유하게 식별합니다.Uniquely identifies the format of the byte[] returned by the Promote method when the transaction is promoted.

(다음에서 상속됨 Transaction)
TransactionInformation

트랜잭션에 대한 추가 정보를 검색합니다.Retrieves additional information about a transaction.

(다음에서 상속됨 Transaction)

메서드

BeginCommitInternal(AsyncCallback) (다음에서 상속됨 Transaction)
Clone()

트랜잭션의 복제본을 만듭니다.Creates a clone of the transaction.

(다음에서 상속됨 Transaction)
Complete()

종속 트랜잭션을 완료하려고 시도합니다.Attempts to complete the dependent transaction.

DependentClone(DependentCloneOption)

트랜잭션의 종속 복제본을 만듭니다.Creates a dependent clone of the transaction.

(다음에서 상속됨 Transaction)
Dispose()

개체에서 보유하는 리소스를 해제합니다.Releases the resources that are held by the object.

(다음에서 상속됨 Transaction)
EndCommitInternal(IAsyncResult) (다음에서 상속됨 Transaction)
EnlistDurable(Guid, IEnlistmentNotification, EnlistmentOptions)

트랜잭션에 참여할 2단계 커밋을 지원하는 영속적 리소스 관리자를 참여시킵니다.Enlists a durable resource manager that supports two phase commit to participate in a transaction.

(다음에서 상속됨 Transaction)
EnlistDurable(Guid, ISinglePhaseNotification, EnlistmentOptions)

트랜잭션에 참여할 1단계 커밋 최적화를 지원하는 영속적 리소스 관리자를 참여시킵니다.Enlists a durable resource manager that supports single phase commit optimization to participate in a transaction.

(다음에서 상속됨 Transaction)
EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification)

PSPE(Promotable Single Phase Enlistment)를 통해 내부 트랜잭션이 있는 리소스 관리자를 등록합니다.Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

(다음에서 상속됨 Transaction)
EnlistPromotableSinglePhase(IPromotableSinglePhaseNotification, Guid)

PSPE(Promotable Single Phase Enlistment)를 통해 내부 트랜잭션이 있는 리소스 관리자를 등록합니다.Enlists a resource manager that has an internal transaction using a promotable single phase enlistment (PSPE).

(다음에서 상속됨 Transaction)
EnlistVolatile(IEnlistmentNotification, EnlistmentOptions)

트랜잭션에 참여하기 위해 2단계 커밋을 지원하는 일시적 리소스 관리자를 등록합니다.Enlists a volatile resource manager that supports two phase commit to participate in a transaction.

(다음에서 상속됨 Transaction)
EnlistVolatile(ISinglePhaseNotification, EnlistmentOptions)

트랜잭션에 참여할 1단계 커밋 최적화를 지원하는 일시적 리소스 관리자를 참여시킵니다.Enlists a volatile resource manager that supports single phase commit optimization to participate in a transaction.

(다음에서 상속됨 Transaction)
Equals(Object)

이 트랜잭션과 지정된 개체가 같은지 여부를 확인합니다.Determines whether this transaction and the specified object are equal.

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

이 인스턴스의 해시 코드를 반환합니다.Returns the hash code for this instance.

(다음에서 상속됨 Transaction)
GetPromotedToken()

트랜잭션을 승격할 때 확장 메서드가 반환한 byte[]를 가져옵니다.Gets the byte[] returned by the Promote method when the transaction is promoted.

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

현재 인스턴스의 Type을 가져옵니다.Gets the Type of the current instance.

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

현재 Object의 단순 복사본을 만듭니다.Creates a shallow copy of the current Object.

(다음에서 상속됨 Object)
PromoteAndEnlistDurable(Guid, IPromotableSinglePhaseNotification, ISinglePhaseNotification, EnlistmentOptions)

트랜잭션에 참여할 2단계 커밋을 지원하는 영속적 리소스 관리자를 승격 및 참여시킵니다.Promotes and enlists a durable resource manager that supports two phase commit to participate in a transaction.

(다음에서 상속됨 Transaction)
Rollback()

트랜잭션을 롤백(중단)합니다.Rolls back (aborts) the transaction.

(다음에서 상속됨 Transaction)
Rollback(Exception)

트랜잭션을 롤백(중단)합니다.Rolls back (aborts) the transaction.

(다음에서 상속됨 Transaction)
SetDistributedTransactionIdentifier(IPromotableSinglePhaseNotification, Guid)

비MSDTC 프로모터를 통해 생성된 분산 트랜잭션 식별자를 설정합니다.Sets the distributed transaction identifier generated by the non-MSDTC promoter.

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

현재 개체를 나타내는 string을 반환합니다.Returns a string that represents the current object.

(다음에서 상속됨 Object)

이벤트

TransactionCompleted

트랜잭션이 완료되었음을 나타냅니다.Indicates that the transaction is completed.

(다음에서 상속됨 Transaction)

명시적 인터페이스 구현

ISerializable.GetObjectData(SerializationInfo, StreamingContext)

적용 대상

스레드 보안

이 형식은 스레드로부터 안전합니다.This type is thread safe.

추가 정보