System.Threading.LazyThreadSafetyMode.ExecutionAndPublication Field

Locks are used to ensure that only a single thread can initialize a Lazy`1 instance in a thread-safe manner. If the initialization method (or the default constructor, if there is no initialization method) uses locks internally, deadlocks can occur. If you use a Lazy`1 constructor that specifies an initialization method (valueFactory parameter), and if that initialization method throws an exception (or fails to handle an exception) the first time you call the Lazy`1.Value property, then the exception is cached and thrown again on subsequent calls to the Lazy`1.Value property. If you use a Lazy`1 constructor that does not specify an initialization method, exceptions that are thrown by the default constructor for T are not cached. In that case, a subsequent call to the Lazy`1.Value property might successfully initialize the Lazy`1 instance. If the initialization method recursively accesses the Lazy`1.Value property of the Lazy`1 instance, an InvalidOperationException is thrown.

Syntax

LazyThreadSafetyMode ExecutionAndPublication

Requirements

Namespace: System.Threading
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 4.0.0.0