Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ EnsureInitializedCore< T >() [2/3]

static T System.Threading.LazyInitializer.EnsureInitializedCore< T > ( [NotNull] ref T target,
[NotNull] ref object syncLock,
Func< T > valueFactory )
inlinestaticprivate
Type Constraints
T :class 

Definition at line 97 of file LazyInitializer.cs.

97 : class
98 {
99 lock (EnsureLockInitialized(ref syncLock))
100 {
101 if (Volatile.Read(ref target) == null)
102 {
103 Volatile.Write(ref target, valueFactory());
104 if (target == null)
105 {
106 throw new InvalidOperationException(SR.Lazy_StaticInit_InvalidOperation);
107 }
108 }
109 }
110 return target;
111 }
static object EnsureLockInitialized([NotNull] ref object syncLock)

References System.Threading.LazyInitializer.EnsureLockInitialized(), System.SR.Lazy_StaticInit_InvalidOperation, System.Threading.Volatile.Read(), and System.Threading.Volatile.Write().