public void Step(ITestPattern testPattern, IWorkerStrategy workerStrategy, CancellationToken cancelToken)
 {
     for (int i = 0; !cancelToken.IsCancellationRequested && i < this.StepIncrease && this.WorkerCount <= this.MaxWorkers; i++)
     {
         workerStrategy.SpawnWorker(testPattern, cancelToken);
     }
 }
        public async Task ExecuteAsync(ITestPattern testPattern, IWorkerStrategy workerStrategy, CancellationToken cancelToken)
        {
            while ((!cancelToken.IsCancellationRequested) && (this.WorkerCount < this.MaxWorkers))
            {
                this.Step(testPattern, workerStrategy, cancelToken);

                if ((!cancelToken.IsCancellationRequested) && (this.WorkerCount < this.MaxWorkers))
                {
                    await Task.Delay(this.StepDuration, cancelToken);
                }
            }
        }
        public void Execute(ITestPattern testPattern, IWorkerStrategy execStrategy, CancellationToken cancelToken)
        {
            ManualResetEventSlim cancelSignaled = new ManualResetEventSlim(false);

            using (cancelToken.Register(() => cancelSignaled.Set()))
            {
                for (int i = 0; i < this.WorkerCount; i++)
                {
                    execStrategy.SpawnWorker(testPattern, cancelToken);
                }

                cancelSignaled.Wait();
            }
        }
        public async Task ExecuteAsync(ITestPattern testPattern, IWorkerStrategy execStrategy, CancellationToken cancelToken)
        {
            SemaphoreSlim cancelSignaled = new SemaphoreSlim(0, 1);

            using (cancelToken.Register(() => cancelSignaled.Release()))
            {
                for (int i = 0; i < this.WorkerCount; i++)
                {
                    execStrategy.SpawnWorker(testPattern, cancelToken);
                }

                await cancelSignaled.WaitAsync();
            }
        }
 public void Execute(ITestPattern testPattern, IWorkerStrategy execStrategy, CancellationToken cancelToken)
 {
     this.ExecuteAsync(testPattern, execStrategy, cancelToken).GetAwaiter().GetResult();
 }