protected override async Task CreateCoWorkerAndExecuteAsync(IWorkerReceiver broadcaster, WorkerConnectionGroupContext workerConnection, string workerName, CancellationToken cancellationToken, TaskFailSignal failSignal) { var loopCount = maxWorkerPerProcess / workerSpawnCount; for (int i = 0; i < loopCount; i++) { // Worker CreateCoWorker logger.LogTrace("Send CreateWorker/Setup command to workers and wait complete message."); workerConnection.OnCreateCoWorkerAndSetup.Reset(); broadcaster.CreateCoWorkerAndSetup(workerSpawnCount, workerName); await workerConnection.OnCreateCoWorkerAndSetup.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task); // Worker Execute if (i == 0) { logger.LogTrace("Send Execute command to workers."); broadcaster.ExecuteUntilReceiveStop(); } // Wait Spawn. await Task.Delay(TimeSpan.FromSeconds(workerSpawnSecond)); } // Send Stop Command logger.LogTrace("Send Stop command to workers."); broadcaster.Stop(); // Wait Execute Complete. await workerConnection.OnExecute.WaitWithTimeoutAsync(options.Timeout, cancellationToken, failSignal.Task); }
public void CancelAll() { logger.LogInformation($"Send cancel command to all workers."); broadcaster?.Stop(); }