Exemplo n.º 1
0
        T GetValueThreadLocal()
        {
            DataSlotWrapper myWrapper = GetWrapper();

            if (myWrapper.Creating)
            {
                throw new InvalidOperationException("The initialization function attempted to reference Value recursively");
            }

            return(myWrapper.Getter());
        }
Exemplo n.º 2
0
        T GetValueThreadLocal()
        {
            DataSlotWrapper myWrapper = Thread.GetData(localStore) as DataSlotWrapper;

            // In case it's the first time the Thread access its data
            if (myWrapper == null)
            {
                myWrapper = DataSlotCreator();
                Thread.SetData(localStore, myWrapper);
            }

            return(myWrapper.Getter());
        }