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); } }
private void RunWorker(ITestPattern pattern, CancellationToken cancelToken) { while (!cancelToken.IsCancellationRequested) { UnitTest t = pattern.GetNextTest(); t.Execute(); } }
public async Task ExecuteWorkerAsync(ITestPattern pattern, CancellationToken cancelToken) { while (!cancelToken.IsCancellationRequested) { UnitTest test = pattern.GetNextTest(); await this.ExecuteTestAsync(test, 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(); }
public void SpawnWorker(ITestPattern pattern, CancellationToken cancelToken) { Task t = new Task(() => RunWorker(pattern, cancelToken), TaskCreationOptions.LongRunning); t.Start(); }
public void SpawnWorker(ITestPattern pattern, CancellationToken cancelToken) { Task throwaway = this.ExecuteWorkerAsync(pattern, cancelToken); }