TLazyInitializer.EnsureInitialized<T>(T,TFunc) Method

Initializes a target reference type by using a specified function if it hasn't already been initialized.

Namespace: Spring
public
 class function EnsureInitialized<T>(var target: T; const valueFactory: TFunc<T>): T; overload; static;

Type Parameters

T

Parameters

target
Type: T

valueFactory
Type: TFunc<T>

Return Value

Type: T

 

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.