public virtual void AfterCompletion(int status) { if (ShouldUnbindAtCompletion()) { var releaseNecessary = false; if (_holderActive) { // The thread-bound resource holder might not be available anymore, // since afterCompletion might get called from a different thread. _holderActive = false; TransactionSynchronizationManager.UnbindResourceIfPossible(_resourceKey); _resourceHolder.Unbound(); releaseNecessary = true; } else { releaseNecessary = ShouldReleaseAfterCompletion(_resourceHolder); } if (releaseNecessary) { ReleaseResource(_resourceHolder, _resourceKey); } } else { // Probably a pre-bound resource... CleanupResource(_resourceHolder, _resourceKey, status == AbstractTransactionSynchronization.STATUS_COMMITTED); } _resourceHolder.Reset(); }