ThreadLocal<T> Constructor (Func<T>^, Boolean)
Initializes the ThreadLocal<T> instance with the specified valueFactory function and a flag that indicates whether all values are accessible from any thread.
Assembly: mscorlib (in mscorlib.dll)
Parameters
- valueFactory
-
Type:
System::Func<T>^
The Func<TResult> invoked to produce a lazily-initialized value when an attempt is made to retrieve Value without it having been previously initialized.
- trackAllValues
-
Type:
System::Boolean
true to track all values set on the instance and expose them through the Values property; false otherwise.
| Exception | Condition |
|---|---|
| ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic). |
If trackAllValues is false, only the value of this instance for the current thread is accessible. Attempting to use the Values property to retrieve all values throws an InvalidOperationException exception.
Available since 8
.NET Framework
Available since 4.5
Portable Class Library
Supported in: portable .NET platforms
Windows Phone Silverlight
Available since 8.0
Windows Phone
Available since 8.1