protected void WaitForLatch(CountDownLatch latch, IParamHolder <Exception> exHolder) { while (true) { if (exHolder.Value != null) { // A parallel exception will be thrown here Exception ex = exHolder.Value; throw ex; } try { latch.Await(); if (latch.GetCount() == 0) { return; } } catch (ThreadInterruptedException) { // intended blank } } }
internal virtual void MarkComplete() { Preconditions.CheckState(completionLatch.GetCount() == 1, "Context already completed!" ); completionLatch.CountDown(); }