Thread-local-storage: Named 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()
    {
        Thread.SetData(Thread.AllocateNamedDataSlot("TestSlot"), 126);
        int slotValue2 = (int)Thread.GetData(Thread.GetNamedDataSlot("TestSlot"));
        Console.WriteLine(slotValue2);
    }
}
126








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