Thread-local-storage: Unnamed slots : LocalDataStoreSlot « Thread « C# / CSharp Tutorial






using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime;
using System.Runtime.CompilerServices;
using System.Security;
using System.Text;

public class MainClass
{
    public static void Main()
    {
        LocalDataStoreSlot slot = Thread.AllocateDataSlot();
        Thread.SetData(slot, 63);

        int slotValue1 = (int)Thread.GetData(slot);
        Console.WriteLine(slotValue1);

    }
}
63








20.26.LocalDataStoreSlot
20.26.1.Thread-local-storage: Unnamed slots
20.26.2.Thread-local-storage: Named slots
20.26.3.Use LocalDataStoreSlot
20.26.4.Thread-static local-storage
20.26.5.Use thread-local storage