public WorkerEventLoopGroup(DispatcherEventLoop dispatcherLoop, int eventLoopCount)
        {
            Contract.Requires(dispatcherLoop != null);

            this.dispatcherLoop = dispatcherLoop;
            this.dispatcherLoop.PipeStartTask.Wait(StartTimeout);
            this.PipeName = this.dispatcherLoop.PipeName;

            this.eventLoops = new IEventLoop[eventLoopCount];
            var terminationTasks = new Task[eventLoopCount];

            for (int i = 0; i < eventLoopCount; i++)
            {
                WorkerEventLoop eventLoop;
                bool            success = false;
                try
                {
                    eventLoop = new WorkerEventLoop(this);
                    eventLoop.StartAsync().Wait(StartTimeout);

                    success = true;
                }
                catch (Exception ex)
                {
                    throw new InvalidOperationException("failed to create a child event loop.", ex);
                }
                finally
                {
                    if (!success)
                    {
                        Task.WhenAll(this.eventLoops.Take(i).Select(loop => loop.ShutdownGracefullyAsync()))
                        .Wait();
                    }
                }

                this.eventLoops[i]  = eventLoop;
                terminationTasks[i] = eventLoop.TerminationCompletion;
            }

            this.TerminationCompletion = Task.WhenAll(terminationTasks);
        }