private void DoPreparePhase() { // Call prepare on all volatile managers. foreach (IEnlistmentNotification enlist in this.Volatiles) { var pe = new PreparingEnlistment(this, enlist); ThreadPool.QueueUserWorkItem(PrepareCallbackWrapper, pe); /* Wait (with timeout) for manager to prepare */ TimeSpan timeout = this.Scope != null ? this.Scope.Timeout : TransactionManager.DefaultTimeout; // FIXME: Should we managers in parallel or on-by-one? if (!pe.WaitHandle.WaitOne(timeout)) { this.Aborted = true; throw new TimeoutException("Transaction timedout"); } if (pe.Exception != null) { this.innerException = pe.Exception; this.Aborted = true; break; } if (!pe.IsPrepared) { /* FIXME: if not prepared & !aborted as yet, then this is inDoubt ? . For now, setting aborted = true */ this.Aborted = true; break; } } /* Either InDoubt(tmp) or Prepare failed and Tx has rolledback */ this.CheckAborted(); }
public void Prepare(PreparingEnlistment preparingEnlistment) { if (_transaction.IsValid(false) == false) preparingEnlistment.ForceRollback(); else preparingEnlistment.Prepared(); }