public static T EnsureInitialized<T> (ref T target, Func<T> initFunc) where T : class
{
- Interlocked.CompareExchange (ref target, initFunc (), null);
+ if (target == null)
+ Interlocked.CompareExchange (ref target, initFunc (), null);
return target;
}