container icon indicating copy to clipboard operation
container copied to clipboard

Optimize PerThreadLifetimeManager

Open ENikS opened this issue 6 years ago • 0 comments

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.

ENikS avatar May 27 '20 02:05 ENikS