示例#1
0
        public async Task ParseAsync()
        {
            var logic = factory.GetLogic();

            foreach (var context in factory.GetContexts())
            {
                var urls = await context.GetPages();

                var counter = 0;

                await urls.ParallelForEachAsync((url) =>
                {
                    Interlocked.Increment(ref counter);
                    Console.WriteLine($"Parsing recipe {counter} of {urls.Count()} in {Thread.CurrentThread.ManagedThreadId} thread.");
                    return(ProcessRecipe(url, context, logic));
                }, Environment.ProcessorCount);
            }
        }