Пример #1
0
        public void Execute(int maxDegreeOfParallelism)
        {
            var semaphore     = new SemaphoreSlim(maxDegreeOfParallelism);
            var tableRenderer = new TableRenderer(_table, Output.Fancy);

            Parallel.ForEach(_parameters, (parameter, state, index) =>
            {
                try
                {
                    semaphore.Wait();
                    var progress = new CustomProgress <TReport>((report) => _progressHandler(report, _table.GetRow((int)index)));

                    _executor(parameter, progress);
                }
                finally
                {
                    semaphore.Release();
                }
            });

            tableRenderer.Dispose();
        }