IEnlistmentNotification.Prepare Method (PreparingEnlistment)
Notifies an enlisted object that a transaction is being prepared for commitment.
Assembly: System.Transactions (in System.Transactions.dll)
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.
Available since 2.0