Пример #1
0
        public void Setup()
        {
            var slot1 = Thread.AllocateNamedDataSlot("SlotPrimitive");

            Thread.SetData(slot1, 0);
            var slot2 = Thread.AllocateNamedDataSlot("SlotManaged");

            Thread.SetData(slot2, new SomeData());
            threadValueLocal     = new ThreadLocal <int>(() => 0);
            threadReferenceLocal = new ThreadLocal <SomeData>(() => new SomeData());
            referenceLocal       = new SomeData();
        }
Пример #2
0
        public int ReferenceThreadDataSlot()
        {
            SomeData data = (SomeData)Thread.GetData(Thread.GetNamedDataSlot("SlotManaged"));

            return(data.Field);
        }