LazyInitializer.EnsureInitialized(Of T) Method (T%, Boolean%, Object%, Func(Of T))
[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]
Initializes a target reference or value type with a specified function if it has not already been initialized.
Assembly: mscorlib (in mscorlib.dll)
'Declaration Public Shared Function EnsureInitialized(Of T) ( _ ByRef target As T, _ ByRef initialized As Boolean, _ ByRef syncLock As Object, _ valueFactory As Func(Of T) _ ) As T
Type Parameters
- T
The type of the reference to be initialized.
Parameters
- target
- Type:
T
%
A reference or value of type T to initialize if it has not already been initialized.
- initialized
- Type:
System.Boolean
%
A reference to a boolean that determines whether the target has already been initialized.
- syncLock
- Type:
System.Object
%
A reference to an object used as the mutually exclusive lock for initializing target. If syncLock is null (Nothing in Visual Basic), a new object will be instantiated.
- valueFactory
- Type: System.Func(Of T)
The Func(Of TResult) invoked to initialize the reference or value.
Return Value
Type: TThe initialized value of type T.
| Exception | Condition |
|---|---|
| MemberAccessException | Permissions to access the constructor of type T were missing. |
| MissingMemberException | Type T does not have a default constructor. |
Show: