System.LocalDataStoreSlot Class

Encapsulates a memory slot to store local data. This class cannot be inherited.

See Also: LocalDataStoreSlot Members

Syntax

[System.Runtime.InteropServices.ComVisible(true)]
public sealed class LocalDataStoreSlot

Remarks

The .NET Framework provides two mechanisms for using thread local storage (TLS): thread-relative static fields and data slots.

For more information about using TLS, see Thread Local Storage: Thread-Relative Static Fields and Data Slots.

Similarly, the .NET Framework provides two mechanisms for using context local storage: context-relative static fields and data slots. Context-relative static fields are static fields that are marked with the ContextStaticAttribute attribute. The trade-offs between using these two mechanisms are similar to the tradeoffs between using thread-relative static fields and data slots.

The LocalDataStoreSlot structure serves as a local store memory mechanism that threads and contexts can use to store thread-specific and context-specific data, respectively. The common language runtime allocates a multi-slot data store array to each process when it is created. The thread or context calls various functions to allocate a data slot in the data store, to store and retrieve a data value in the slot, and to free a data slot for reuse after the thread or context object expires.

The data slots are unique per thread or context; their values are not shared between the thread or context objects. Data slots can be allocated by a name or by an index number.

For more information about storing local data, see System.Threading.Thread or System.Runtime.Remoting.Contexts.Context. The LocalDataStoreSlot class is used with methods such as System.Threading.Thread.AllocateNamedDataSlot(string), System.Runtime.Remoting.Contexts.Context.AllocateNamedDataSlot(string), System.Threading.Thread.GetData(LocalDataStoreSlot), and System.Runtime.Remoting.Contexts.Context.GetData(LocalDataStoreSlot); it does not have any methods of its own that you need to use.

Requirements

Namespace: System
Assembly: mscorlib (in mscorlib.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0