protected override async Task StartCore(IWorkerRunner workerRunner, IQueueWorker queueWorker, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested || !queueWorker.IsEmpty) { await queueWorker.ReceiveAsync() .ContinueWith(async invoker => await workerRunner.ExcecuteInvoker(await invoker), TaskContinuationOptions.OnlyOnRanToCompletion); } }
protected override async Task StartCore(IWorkerRunner workerRunner, IQueueWorker queueWorker, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested || !queueWorker.IsEmpty) { var invoker = await queueWorker.ReceiveAsync(); await workerRunner.ExcecuteInvoker(invoker); } }
protected override async Task StartCore(IWorkerRunner workerRunner, IQueueWorker queueWorker, CancellationToken cancellationToken) { while (!cancellationToken.IsCancellationRequested || !queueWorker.IsEmpty) { await _threadLimit.WaitAsync() .ContinueWith(async t => await queueWorker.ReceiveAsync() .ContinueWith(async invoker => await workerRunner.ExcecuteInvoker(await invoker) .ContinueWith(t2 => _threadLimit.Release())) ); } }