Commit acd8a6da authored by Michael Denny's avatar Michael Denny

Fix concurrency issue on TypeData

parent 6c6f2fb8
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Reflection;
......@@ -11,7 +12,7 @@ namespace Syroot.BinaryData
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private static readonly Dictionary<Type, TypeData> _cache = new Dictionary<Type, TypeData>();
private static readonly ConcurrentDictionary<Type, TypeData> _cache = new ConcurrentDictionary<Type, TypeData>();
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
......@@ -86,7 +87,7 @@ namespace Syroot.BinaryData
if (!_cache.TryGetValue(type, out TypeData typeData))
{
typeData = new TypeData(type);
_cache.Add(type, typeData);
_cache.TryAdd(type, typeData);
}
return typeData;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment