void IDisposable.Dispose() { IAsyncResult result; if (this.State == AsyncResult.TransactionSignalState.Ready) { this.State = AsyncResult.TransactionSignalState.Abandoned; } else if (this.State == AsyncResult.TransactionSignalState.Prepared) { this.State = AsyncResult.TransactionSignalState.Completed; } else { AsyncResult.ThrowInvalidAsyncResult("PrepareTransactionalCall should only be called in a using. Dispose called multiple times."); } try { Fx.CompleteTransactionScope(ref this.transactionScope); } catch (Exception exception) { if (Fx.IsFatal(exception)) { throw; } throw Fx.Exception.AsError(new InvalidOperationException(SRCore.AsyncTransactionException)); } if ((this.State == AsyncResult.TransactionSignalState.Completed) && base.Unlock(out result)) { if (this.parent.deferredTransactionalResult != null) { AsyncResult.ThrowInvalidAsyncResult(this.parent.deferredTransactionalResult); } this.parent.deferredTransactionalResult = result; } }