Export (0) Print
Expand All

LocalDataStoreSlot Class

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

System.Object
  System.LocalDataStoreSlot

Namespace:  System
Assembly:  mscorlib (in mscorlib.dll)

[ComVisibleAttribute(true)]
public sealed class LocalDataStoreSlot

The LocalDataStoreSlot type exposes the following members.

  NameDescription
Public methodSupported by the XNA FrameworkEquals(Object)Determines whether the specified object is equal to the current object. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetHashCodeServes as the default hash function. (Inherited from Object.)
Public methodSupported by the XNA FrameworkGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodSupported by the XNA FrameworkToStringReturns a string that represents the current object. (Inherited from Object.)
Top

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

  • Thread-relative static fields are static fields (Shared fields in Visual Basic) that are marked with the ThreadStaticAttribute attribute. They provide better performance than data slots, and enable compile-time type checking.

  • Data slots are slower and more awkward to use than thread-relative static fields. Also, data is stored as type Object, so you must cast it to the correct type before using it. However, you can use data slots when you have insufficient information at compile time to allocate static fields.

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 Thread or Context. The LocalDataStoreSlot class is used with methods such as Thread.AllocateNamedDataSlot, Context.AllocateNamedDataSlot, Thread.GetData, and Context.GetData; it does not have any methods of its own that you need to use.

.NET Framework

Supported in: 4.6, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft