TLazyInitializer.EnsureInitialized<T> Method
Overloads
| EnsureInitialized<T>(T) |
Initializes a target reference type by using a specified function if it hasn't already been initialized. |
| EnsureInitialized<T>(T, Func<T>) |
Initializes a target reference type by using a specified function if it hasn't already been initialized. |
Initializes a target reference type by using a specified function if it hasn't already been initialized.
class function EnsureInitialized<T>(var target: T): T
Type Parameters
- T
Parameters
- target
- T
Returns
Remarks
In the event that multiple threads access this method concurrently, multiple instances of T may be created, but only one will be stored into target. In such an occurrence, this method will destroy the instances that were not stored.
Initializes a target reference type by using a specified function if it hasn't already been initialized.
class function EnsureInitialized<T>(var target: T; const valueFactory: Func<T>): T
Type Parameters
- T
Parameters
- target
- T
- valueFactory
- Func<T>
Returns
Remarks
This method may only be used on reference types, and valueFactory may not return a nil reference.
In the event that multiple threads access this method concurrently, multiple instances of T may be created, but only one will be stored into target. In such an occurrence, this method will destroy the instances that were not stored.