private static void OnHostTransaction(object state, TimeoutException timeoutException) { InstanceHandle.AcquireContextAsyncResult result = (InstanceHandle.AcquireContextAsyncResult)state; Exception exception = timeoutException; bool flag = exception != null; if (!flag) { try { if (result.DoAfterTransaction()) { flag = true; } } catch (Exception exception2) { if (Fx.IsFatal(exception2)) { throw; } exception = exception2; flag = true; } } if (flag) { if (exception != null) { result.handle.FinishOperation(); } result.Complete(false, exception); } }
private bool DoAfterTransaction() { InstanceHandle.AcquireContextAsyncResult result = null; try { lock (this.handle.ThisLock) { if (!this.handle.IsValid) { throw Fx.Exception.AsError(new OperationCanceledException(SRCore.HandleFreed)); } if (this.HostTransaction == null) { this.executionContext = new InstancePersistenceContext(this.handle, this.timeoutHelper.RemainingTime()); } else { this.executionContext = new InstancePersistenceContext(this.handle, this.HostTransaction); } this.handle.AcquirePending = null; this.handle.CurrentExecutionContext = this.executionContext; this.handle.TooLateToEnlist = false; } if (this.HostTransaction != null) { this.WaitForHostTransaction = new AsyncWaitHandle(EventResetMode.ManualReset); this.HostTransaction.EnlistVolatile(this, EnlistmentOptions.None); result = this; } } finally { this.handle.CurrentTransactionalAsyncResult = result; } return(true); }