예제 #1
0
        private void ProcessTask(CancellationToken token, string task)
        {
            var attempts = 0;

            while (!token.IsCancellationRequested)
            {
                try
                {
                    var charCount = _worker.Work(task);
                    _writer.Write(task, charCount);
                    return;
                }
                catch (IOException ex)
                {
                    _logger.Error(ex, $"Во время чтения файла {task} произошла ошибка.");
                    attempts++;
                    if (attempts >= 3)
                    {
                        _logger.Error($"Файл {task} не обработан.");
                    }
                    else
                    {
                        Task.Delay(10000, token);
                    }
                }
            }
        }
예제 #2
0
        public void Process(string subword)
        {
            var loadResult = LoadWordsAndDisplayErrorOnFail();

            if (!loadResult.Passed)
            {
                return;
            }

            var candidateWords = CreateCandidateListFor(subword);

            ExtractWordsWithMeaningfulCandidates(candidateWords);

            _resultsWriter.Write(_finalList.ToList().OrderBy(word => word));
        }