Provides thread-local storage of data.
More...
|
| ThreadLocal () |
| Initializes the T:System.Threading.ThreadLocal`1 instance. More...
|
|
| ThreadLocal (bool trackAllValues) |
| Initializes the T:System.Threading.ThreadLocal`1 instance and specifies whether all values are accessible from any thread. More...
|
|
| ThreadLocal (Func< T > valueFactory) |
| Initializes the T:System.Threading.ThreadLocal`1 instance with the specified valueFactory function. More...
|
|
| ThreadLocal (Func< T > valueFactory, bool trackAllValues) |
| Initializes the T:System.Threading.ThreadLocal`1 instance with the specified valueFactory function and a flag that indicates whether all values are accessible from any thread. More...
|
|
void | Dispose () |
| Releases all resources used by the current instance of the T:System.Threading.ThreadLocal`1 class. More...
|
|
override string | ToString () |
| Creates and returns a string representation of this instance for the current thread. More...
|
|
|
virtual void | Dispose (bool disposing) |
| Releases the resources used by this T:System.Threading.ThreadLocal`1 instance. More...
|
|
|
T | Value [get, set] |
| Gets or sets the value of this instance for the current thread. More...
|
|
IList< T > | Values [get] |
| Gets a list for all of the values currently stored by all of the threads that have accessed this instance. More...
|
|
bool | IsValueCreated [get] |
| Gets whether P:System.Threading.ThreadLocal`1.Value is initialized on the current thread. More...
|
|
Provides thread-local storage of data.
- Template Parameters
-
T | Specifies the type of data stored per-thread. |
Definition at line 13 of file ThreadLocal.cs.
◆ ThreadLocal() [1/4]
Initializes the T:System.Threading.ThreadLocal`1 instance.
Definition at line 251 of file ThreadLocal.cs.
◆ ThreadLocal() [2/4]
Initializes the T:System.Threading.ThreadLocal`1 instance and specifies whether all values are accessible from any thread.
- Parameters
-
trackAllValues | true to track all values set on the instance and expose them through the P:System.Threading.ThreadLocal`1.Values property; false otherwise. |
Definition at line 260 of file ThreadLocal.cs.
◆ ThreadLocal() [3/4]
Initializes the T:System.Threading.ThreadLocal`1 instance with the specified valueFactory function.
- Parameters
-
valueFactory | The T:System.Func`1 invoked to produce a lazily-initialized value when an attempt is made to retrieve P:System.Threading.ThreadLocal`1.Value without it having been previously initialized. |
- Exceptions
-
T:System.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic). |
Definition at line 270 of file ThreadLocal.cs.
◆ ThreadLocal() [4/4]
Initializes the T:System.Threading.ThreadLocal`1 instance with the specified valueFactory function and a flag that indicates whether all values are accessible from any thread.
- Parameters
-
valueFactory | The T:System.Func`1 invoked to produce a lazily-initialized value when an attempt is made to retrieve P:System.Threading.ThreadLocal`1.Value without it having been previously initialized. |
trackAllValues | true to track all values set on the instance and expose them through the P:System.Threading.ThreadLocal`1.Values property; false otherwise. |
- Exceptions
-
T:System.ArgumentNullException | valueFactory is a null reference (Nothing in Visual Basic). |
Definition at line 286 of file ThreadLocal.cs.
◆ Dispose() [1/2]
Releases all resources used by the current instance of the T:System.Threading.ThreadLocal`1 class.
Implements System.IDisposable.
Definition at line 318 of file ThreadLocal.cs.
◆ Dispose() [2/2]
Releases the resources used by this T:System.Threading.ThreadLocal`1 instance.
- Parameters
-
disposing | A Boolean value that indicates whether this method is being called due to a call to M:System.Threading.ThreadLocal`1.Dispose. |
Definition at line 327 of file ThreadLocal.cs.
◆ ToString()
Creates and returns a string representation of this instance for the current thread.
- Returns
- The result of calling M:System.Object.ToString on the P:System.Threading.ThreadLocal`1.Value.
- Exceptions
-
T:System.ObjectDisposedException | The T:System.Threading.ThreadLocal`1 instance has been disposed. |
T:System.NullReferenceException | The P:System.Threading.ThreadLocal`1.Value for the current thread is a null reference (Nothing in Visual Basic). |
T:System.InvalidOperationException | The initialization function attempted to reference P:System.Threading.ThreadLocal`1.Value recursively. |
T:System.MissingMemberException | No default constructor is provided and no value factory is supplied. |
Definition at line 361 of file ThreadLocal.cs.
◆ IsValueCreated
Gets whether P:System.Threading.ThreadLocal`1.Value is initialized on the current thread.
- Returns
- true if P:System.Threading.ThreadLocal`1.Value is initialized on the current thread; otherwise false.
- Exceptions
-
T:System.ObjectDisposedException | The T:System.Threading.ThreadLocal`1 instance has been disposed. |
Definition at line 214 of file ThreadLocal.cs.
◆ Value
Gets or sets the value of this instance for the current thread.
- Returns
- Returns an instance of the object that this ThreadLocal is responsible for initializing.
- Exceptions
-
T:System.ObjectDisposedException | The T:System.Threading.ThreadLocal`1 instance has been disposed. |
T:System.InvalidOperationException | The initialization function attempted to reference P:System.Threading.ThreadLocal`1.Value recursively. |
T:System.MissingMemberException | No default constructor is provided and no value factory is supplied. |
Definition at line 143 of file ThreadLocal.cs.
◆ Values
Gets a list for all of the values currently stored by all of the threads that have accessed this instance.
- Returns
- A list for all of the values currently stored by all of the threads that have accessed this instance.
- Exceptions
-
T:System.InvalidOperationException | Values stored by all threads are not available because this instance was initialized with the trackAllValues argument set to false in the call to a class constructor. |
T:System.ObjectDisposedException | The T:System.Threading.ThreadLocal`1 instance has been disposed. |
Definition at line 179 of file ThreadLocal.cs.
The documentation for this class was generated from the following file: