ThreadLocal<T> Class
Provides thread-local storage of data.
Assembly: mscorlib (in mscorlib.dll)
The ThreadLocal<T> type exposes the following members.
| Name | Description | |
|---|---|---|
![]() | ThreadLocal<T>() | Initializes the ThreadLocal<T> instance. |
![]() | ThreadLocal<T>(Func<T>) | Initializes the ThreadLocal<T> instance with the specified valueFactory function. |
| Name | Description | |
|---|---|---|
![]() | IsValueCreated | Gets whether Value is initialized on the current thread. |
![]() | Value | Gets or sets the value of this instance for the current thread. |
| Name | Description | |
|---|---|---|
![]() | Dispose() | Releases all resources used by the current instance of the ThreadLocal<T> class. |
![]() | Dispose(Boolean) | Releases the resources used by this ThreadLocal<T> instance. |
![]() | Equals(Object) | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) |
![]() | Finalize | Releases the resources used by this ThreadLocal<T> instance. (Overrides Object::Finalize().) |
![]() | GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) |
![]() | GetType | Gets the Type of the current instance. (Inherited from Object.) |
![]() | MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() | ToString | Creates and returns a string representation of this instance for the current thread. (Overrides Object::ToString().) |
Note |
|---|
The HostProtectionAttribute attribute applied to this type or member has the following Resources property value: Synchronization | ExternalThreading. The HostProtectionAttribute does not affect desktop applications (which are typically started by double-clicking an icon, typing a command, or entering a URL in a browser). For more information, see the HostProtectionAttribute class or SQL Server Programming and Host Protection Attributes. |
Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
With the exception of Dispose, all public and protected members of ThreadLocal<T> thread-safe and may be used concurrently from multiple threads. The value returned for the Value and IsValueCreated properties is specific for the thread on which the property is accessed.
