public async Task <int> CountWordsFromTextSourceAsync( ITextSource source, CancellationToken token) { _logger.Debug($"Counting Words on [{source.TextSourceId}]"); int wordCount; if (_wordCountCache.TryGet(source.TextSourceId, out wordCount)) { return(wordCount); } var text = await source.GetTextAsync(token); wordCount = _wordCountingAlgorithm.CountWordsInString(text); _wordCountCache.Add(source.TextSourceId, wordCount); return(wordCount); }