IEnlistmentNotification.Prepare Method

Notifies an enlisted object that a transaction is being prepared for commitment.

Namespace:  System.Transactions
Assembly:  System.Transactions (in System.Transactions.dll)

void Prepare(
	PreparingEnlistment preparingEnlistment
)

Parameters

preparingEnlistment
Type: System.Transactions.PreparingEnlistment

A PreparingEnlistment object used to send a response to the transaction manager.

The transaction manager calls this method of an enlisted resource manager during the phase 1 of a commitment, when it asks participants whether they can commit the transaction.

When you are implementing a durable resource manager, you should log your prepare record during this phase. The record should contain all the necessary information to perform recovery. This includes the RecoveryInformation property, which is passed to the transaction manager in the Reenlist method during recovery. For more information on recovery, see Performing Recovery.

Your resource manager should complete all work that must be finished before calling the Prepared method of the preparingEnlistment parameter to indicate its vote for commitment. You should make sure that this is accomplished before receiving any phase 2 notification such as commit, rollback or in doubt. This is because phase 2 notifications can happen inline on the same thread that called the Prepared method in phase 1. As such, you should not do any work after the Prepared call (for example, releasing locks) that you would expect to have completed before receiving the phase 2 notifications.

You can also call the method of the preparingEnlistment parameter to indicate a vote for rollback.

If you want the object to merely observe and react to the progress of the transaction, without participating in it, your implementation of this method should call the Done method of the preparingEnlistment parameter when it has finished its work. By doing so, your resource manager would not receive any phase 2 notification.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
Was this page helpful?
(1500 characters remaining)
Thank you for your feedback
Show:
© 2015 Microsoft