// Method called when the connection is put back into the pool while it is manually // enlisted in a distributed transaction. We must create an outcome event and let the // connection wait until the distributed transaction has finished. Once it does, we then // put it back into the general population of the pool. private void PutConnectionManualEnlisted(SqlInternalConnection con) { ITransaction transaction = con.ManualEnlistedTransaction; con.ResetCachedTransaction(); // Null out con internal transaction reference con.InPool = true; // Mark as in pool so it will not be reclaimed by CheckForDeadConnections // Create IConnectionPoint object - from ITransaction UCOMIConnectionPoint point = (UCOMIConnectionPoint)transaction; // Create outcome event - passing pool, connection, and the IConnectionPoint object TransactionOutcomeEvents outcomeEvent = new TransactionOutcomeEvents(this, con, point); Int32 cookie = 0; point.Advise(outcomeEvent, out cookie); // Register for callbacks, obtain cookie outcomeEvent.SetCookie(cookie); // Set the cookie on the event }