diff --git a/CryptoExchange.Net/Objects/RequestDefinitionCache.cs b/CryptoExchange.Net/Objects/RequestDefinitionCache.cs index fbd1974..67ac2f1 100644 --- a/CryptoExchange.Net/Objects/RequestDefinitionCache.cs +++ b/CryptoExchange.Net/Objects/RequestDefinitionCache.cs @@ -1,5 +1,6 @@ using CryptoExchange.Net.RateLimiting.Interfaces; using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Net.Http; @@ -10,7 +11,7 @@ namespace CryptoExchange.Net.Objects /// public class RequestDefinitionCache { - private readonly Dictionary _definitions = new(); + private readonly ConcurrentDictionary _definitions = new(); /// /// Get a definition if it is already in the cache or create a new definition and add it to the cache @@ -74,7 +75,7 @@ namespace CryptoExchange.Net.Objects RequestBodyFormat = requestBodyFormat, ParameterPosition = parameterPosition, }; - _definitions.Add(method + path, def); + _definitions.TryAdd(method + path, def); } return def;