How Do I...Enilst on a transaction?
If you want to build a resource manager or simply vote on the outcome of a transaction you'll need to enlist on that transaction. Enlisting allows you to receive transaction notifications and take appropriate action.
There are two steps to enlist on a transaction:
- First, you will need to enlist on a transaction. If your enlistment will not log state information and cannot recover from a failure, call the EnlistVolatile method on the Transaction object. If your enlistment will log state information and can recover from a failure, call the EnlistDurable method on the Transaction object.
- Second, your enlistment will need to implement the IEnlistmentNotification interface. The methods implemented will be called for each of the possible transaction notifications: Prepare, Commit, Rollback, and InDoubt.
Here is a full example:
[This sample can be found at M:\web\users\Sites\AspnetQuickStart\v2.0\QuickStart\howto\samples\Transactions\VolatileEnlist
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild
passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin
directory.]
Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.
|