container
container copied to clipboard
Optimize PerThreadLifetimeManager
Problem
Current implementation used [ThreadStatic] variable that requires runtime checks if value has been initialized and than it stores values in a Dictionary.
[ThreadStatic]
private static Dictionary<Guid, object> _values;
private readonly Guid _key = Guid.NewGuid();
Solution
Using ThreadLocal<object> will provide better performance as well as lower memory footprint.