Click to Rate and Give Feedback
MSDN
MSDN Library
.NET Development
.NET Framework 3.5
Collapse All/Expand All Collapse All
This page is specific to
Microsoft Visual Studio 2008/.NET Framework 3.5

Other versions are also available for the following:
.NET Framework Class Library
PreparingEnlistment Class

Facilitates communication between an enlisted transaction participant and the transaction manager during the Prepare phase of the transaction.

Namespace:  System.Transactions
Assembly:  System.Transactions (in System.Transactions.dll)
Visual Basic (Declaration)
Public Class PreparingEnlistment _
    Inherits Enlistment
Visual Basic (Usage)
Dim instance As PreparingEnlistment
C#
public class PreparingEnlistment : Enlistment
Visual C++
public ref class PreparingEnlistment : public Enlistment
JScript
public class PreparingEnlistment extends Enlistment

During the initial (prepare) phase of the transaction, the transaction manager passes this type to the resource manager by calling the Prepare method to obtain a resource's vote on the transaction. Depending on whether it votes to commit or roll back, your implementation of the resource manager should call the Prepared or ForceRollback methods of this type.

The resource manager can also call the Done method at anytime before it has called the Prepared method. By doing so, the enlistment is casting a read only vote, meaning that it votes commit on the transaction but does not need to receive the final outcome.

Durable resource managers can retrieve the information that is be needed by the transaction manager for re-enlistment from the RecoveryInformation property. For more information on recovery, see Performing Recovery.

Visual Basic
    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
C#
        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();
            }
        }
Visual Basic
    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
C#
        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

This type is thread safe.

Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98

The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

.NET Framework

Supported in: 3.5, 3.0, 2.0
Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement | Site Feedback
Page view tracker