Ejemplo n.º 1
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            _logger.LogDebug("Sort Service starting");
            stoppingToken.Register(() =>
                                   _logger.LogDebug($" Sort Service background task is stopping."));

            while (!stoppingToken.IsCancellationRequested)
            {
                if (MemoryQueue.GetPendingQueue().Count > 0)
                {
                    foreach (SortJob pendingJob in MemoryQueue.GetPendingQueue())
                    {
                        SortJob completedJob = await _sortJobProcessor.Process(pendingJob);

                        MemoryQueue.UpdateQueue(completedJob);
                    }
                }
                await Task.Delay(5000, stoppingToken);
            }

            _logger.LogDebug("Sort Service background task is stopping.");
        }