diff --git a/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs b/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs index 3af577c..6117742 100644 --- a/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs +++ b/YaeBlog.Core/Abstractions/IPostRenderProcessor.cs @@ -4,7 +4,7 @@ namespace YaeBlog.Core.Abstractions; public interface IPostRenderProcessor { - BlogEssay Process(BlogEssay essay); + Task ProcessAsync(BlogEssay essay); string Name { get; } } diff --git a/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs b/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs index 9762e53..ee3b7f2 100644 --- a/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs +++ b/YaeBlog.Core/Abstractions/IPreRenderProcessor.cs @@ -4,7 +4,7 @@ namespace YaeBlog.Core.Abstractions; public interface IPreRenderProcessor { - BlogContent Process(BlogContent content); + Task ProcessAsync(BlogContent content); string Name { get; } } diff --git a/YaeBlog.Core/Services/RendererService.cs b/YaeBlog.Core/Services/RendererService.cs index 2a463e5..2a7fbf6 100644 --- a/YaeBlog.Core/Services/RendererService.cs +++ b/YaeBlog.Core/Services/RendererService.cs @@ -112,11 +112,11 @@ public class RendererService(ILogger logger, { ConcurrentBag processedContents = []; - Parallel.ForEach(contents, content => + Parallel.ForEachAsync(contents, async (content, _) => { - foreach (IPreRenderProcessor processor in _preRenderProcessors) + foreach (var processor in _preRenderProcessors) { - content = processor.Process(content); + content = await processor.ProcessAsync(content); } processedContents.Add(content); @@ -127,11 +127,11 @@ public class RendererService(ILogger logger, private void PostProcess(IEnumerable essays) { - Parallel.ForEach(essays, essay => + Parallel.ForEachAsync(essays, async (essay, _) => { foreach (IPostRenderProcessor processor in _postRenderProcessors) { - essay = processor.Process(essay); + essay = await processor.ProcessAsync(essay); } if (!essayContentService.TryAdd(essay.FileName, essay)) @@ -139,8 +139,6 @@ public class RendererService(ILogger logger, throw new BlogFileException( $"There are two essays with the same name: '{essay.FileName}'."); } - - logger.LogDebug("Post-Process essay: {}.", essay); }); }