From 4d476dc4828af22964188afb58492a0ac4eb165e Mon Sep 17 00:00:00 2001 From: Corniel Nobel Date: Fri, 17 May 2024 09:01:50 +0200 Subject: [PATCH] Use a ConcurrentDictionary to be thread-safe. --- src/Qowaiv.DomainModel/Commands/CommandProcessor.cs | 7 ++++--- src/Qowaiv.DomainModel/Qowaiv.DomainModel.csproj | 4 +++- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Qowaiv.DomainModel/Commands/CommandProcessor.cs b/src/Qowaiv.DomainModel/Commands/CommandProcessor.cs index 71b9fd7..8a9a919 100644 --- a/src/Qowaiv.DomainModel/Commands/CommandProcessor.cs +++ b/src/Qowaiv.DomainModel/Commands/CommandProcessor.cs @@ -1,4 +1,5 @@ -using System.Linq.Expressions; +using System.Collections.Concurrent; +using System.Linq.Expressions; using System.Reflection; namespace Qowaiv.DomainModel.Commands; @@ -16,7 +17,7 @@ namespace Qowaiv.DomainModel.Commands; public abstract class CommandProcessor { /// Gets the command types sent at least once by the command processor. - public IReadOnlyCollection CommandTypes => handlers.Keys; + public IReadOnlyCollection CommandTypes => [..handlers.Keys]; /// The generic type definition of the command handlers to support. /// @@ -142,5 +143,5 @@ private static Expression> return Expression.Lambda>(body, handler, cmd, token); } - private readonly Dictionary> handlers = new(); + private readonly ConcurrentDictionary> handlers = new(); } diff --git a/src/Qowaiv.DomainModel/Qowaiv.DomainModel.csproj b/src/Qowaiv.DomainModel/Qowaiv.DomainModel.csproj index a19e4e0..0edb6b6 100644 --- a/src/Qowaiv.DomainModel/Qowaiv.DomainModel.csproj +++ b/src/Qowaiv.DomainModel/Qowaiv.DomainModel.csproj @@ -5,8 +5,10 @@ netstandard2.0;net5.0;net6.0;net7.0;net8.0 true - 1.1.0 + 1.1.1 +v1.1.1 +- CommandProcessor made thread-safe. #42 v1.1.0 - Expose supported event types via Aggregate.SupportedEventTypes(). #41 - Publish .NET 8.0.