views:

19

answers:

1

From the MSDN entry for TransactionCompleted:

You can register for this event instead of using a volatile enlistment to get outcome information for transactions.

Caution Signing up for this event negatively affects the performance of the transaction it is attached to.

Does anyone have an example, or even an explanation, of how to enlist in a transaction so as merely to be notified of its completion?

A: 

The MSDN might be a bit misleading here. Registering the event should be at least as fast as enlisting a dummy resource manager (not that I've tested it).

The thing is, if you enlist, the transaction will become a distributed one (since there are now at least two resource managers involved). Such a transaction is slower (more IO with the database server or what ever you work with).

You can still try the enlist way. Just implement IEnlistmentNotification and call enlistment.Done() in every method. You'll also want to add your code to the Commit() method.

Then pass the reference to your implementation to the transaction's EnlistVolatile(..) method (with options set to None).

Lawnmower