public void Prepared() { if (this.State != AsyncResult.TransactionSignalState.Ready) { AsyncResult.ThrowInvalidAsyncResult("PrepareAsyncCompletion should only be called once per PrepareTransactionalCall."); } this.State = AsyncResult.TransactionSignalState.Prepared; }
protected virtual void Dispose(bool disposing) { IAsyncResult asyncResult; if (disposing && !this.disposed) { this.disposed = true; if (this.State == AsyncResult.TransactionSignalState.Ready) { this.State = AsyncResult.TransactionSignalState.Abandoned; } else if (this.State != AsyncResult.TransactionSignalState.Prepared) { AsyncResult.ThrowInvalidAsyncResult("PrepareTransactionalCall should only be called in a using. Dispose called multiple times."); } else { this.State = AsyncResult.TransactionSignalState.Completed; } try { Fx.CompleteTransactionScope(ref this.transactionScope); } catch (Exception exception) { if (!Fx.IsFatal(exception)) { throw Fx.Exception.AsError(new InvalidOperationException(SRCore.AsyncTransactionException), null); } throw; } if (this.State == AsyncResult.TransactionSignalState.Completed && base.Unlock(out asyncResult)) { if (this.parent.deferredTransactionalResult != null) { AsyncResult.ThrowInvalidAsyncResult(this.parent.deferredTransactionalResult); } this.parent.deferredTransactionalResult = asyncResult; } } }