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)

System.Object
  System.Transactions.Enlistment
    System.Transactions.PreparingEnlistment

Public Class PreparingEnlistment
	Inherits Enlistment

NameDescription
System_CAPS_pubmethodDone()

Indicates that the transaction participant has completed its work.(Inherited from Enlistment.)

System_CAPS_pubmethodEquals(Object)

Determines whether the specified object is equal to the current object.(Inherited from Object.)

System_CAPS_protmethodFinalize()

Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.(Inherited from Object.)

System_CAPS_pubmethodForceRollback()

Indicates that the transaction should be rolled back.

System_CAPS_pubmethodForceRollback(Exception)

Indicates that the transaction should be rolled back.

System_CAPS_pubmethodGetHashCode()

Serves as the default hash function. (Inherited from Object.)

System_CAPS_pubmethodGetType()

Gets the Type of the current instance.(Inherited from Object.)

System_CAPS_protmethodMemberwiseClone()

Creates a shallow copy of the current Object.(Inherited from Object.)

System_CAPS_pubmethodPrepared()

Indicates that the transaction can be committed.

System_CAPS_pubmethodRecoveryInformation()

Gets the recovery information of an enlistment.

System_CAPS_pubmethodToString()

Returns a string that represents the current object.(Inherited from Object.)

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.

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

.NET Framework
Available since 2.0

This type is thread safe.

System.Transactions Namespace
Committing A Transaction In Single-Phase and Multi-Phase

Return to top
Show: