public void Execute(EventWaitHandle executionWaitHandle) { try { // REVIEW: This design may allow extra Executes to be invoked, and then block and ultimately terminate the superfluous thread. It works, but can we make it cleaner? lock (_executeLockObject) { if (ExecutionStarted) { return; } ExecutionStarted = true; IIR phaseOutputIR; if (IsRootPhase) { phaseOutputIR = _hostedPhase.Execute(_rootIR); } else { // REVIEW: Ignores which Input IR came from which predecessor IPhase for now. Is this OK? phaseOutputIR = _hostedPhase.Execute(new Collection <IIR>(_predecessorIRs.Values.ToList())); } foreach (PhaseExecutionHost childHost in _successors) { // TODO: Do we need to Clone here? childHost.SupplyIRFromPredecessor(this, phaseOutputIR); } ExecutionComplete = true; executionWaitHandle.Set(); } } catch (Exception) { FatalErrorOccurred = true; executionWaitHandle.Set(); } }