Пример #1
0
        private void DoWork()
        {
            _logger.LogInformation("Segment Background Service is working.");
            while (isRunning)
            {
                var         timeout      = TimeSpan.FromMilliseconds(100);
                List <Task> runningTasks = new List <Task>();
                if (_threadPool.GetLock(1000) > 0)
                {
                    BEMobileSegmentTaskModel t;
                    if (runningTasks.Count == 0)
                    {
                        _logger.LogInformation("Waiting for Segments in queue to process");
                        runningTasks.Add(_queue.DocumentQueue.Take().Execute(_queue));
                        runningTasks.Last().ContinueWith((r) => _threadPool.ReleaseLock());
                    }
                    _logger.LogInformation("Checking for additional segments");
                    while (_queue.DocumentQueue.TryTake(out t, timeout))
                    {
                        if (_threadPool.GetLock(1000) > 0)
                        {
                            runningTasks.Add(t.Execute(_queue));
                            runningTasks.Last().ContinueWith((r) => _threadPool.ReleaseLock());
                        }
                    }

                    _logger.LogInformation("Waiting Segments to finish processing");
                    Task.WaitAll(runningTasks.ToArray <Task>());
                }
            }
        }
Пример #2
0
 private void DoWork()
 {
     _logger.LogInformation("Document Processing Service is working.");
     while (isRunning)
     {
         if (_pool == null || _pool.GetLock(5000) > 0)
         {
             GenericQueueTask <SegmentTaskModel> task = _queue.Queue.Take();
             task.ExecuteTask();
             _pool.ReleaseLock();
         }
     }
 }
Пример #3
0
 private void DoWork()
 {
     _logger.LogInformation("Blob Background Service is working.");
     while (isRunning)
     {
         if (_threadPool.GetLock(10000) > 0)
         {
             BeMobileTaskModel task = _queue.JobQueue.Take();
             _logger.LogInformation("Processing new Blob task from queue");
             task.Execute(_logger, _queue);
             _threadPool.ReleaseLock();
             _logger.LogInformation("Finished processing Blob task from queue");
             _queue.JobsFinished += 1;
         }
     }
 }