public int DeQueue(ref _ThreadPoolWaitCallback callback)
        {
            bool lockTaken = false;
            _ThreadPoolWaitCallback callback2 = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
                Monitor.Enter(this.tpSync, ref lockTaken);
            }
            finally
            {
                if (lockTaken)
                {
                    _ThreadPoolWaitCallback tpHead = this.tpHead;
                    if (tpHead != null)
                    {
                        callback2   = tpHead;
                        this.tpHead = tpHead._next;
                        this.tpCount--;
                        if (this.tpCount == 0)
                        {
                            this.tpTail = null;
                            ThreadPool.ClearAppDomainRequestActive();
                        }
                    }
                    Monitor.Exit(this.tpSync);
                }
            }
            callback = callback2;
            return(this.tpCount);
        }
Esempio n. 2
0
        public _ThreadPoolWaitCallback DeQueue()
        {
            bool flag = false;
            _ThreadPoolWaitCallback callback = null;

            RuntimeHelpers.PrepareConstrainedRegions();
            try
            {
            }
            finally
            {
                RuntimeHelpers.PrepareConstrainedRegions();
                try
                {
                    Monitor.Enter(this.tpSync);
                    flag = true;
                }
                catch (Exception)
                {
                }
                if (flag)
                {
                    _ThreadPoolWaitCallback tpHead = this.tpHead;
                    if (tpHead != null)
                    {
                        callback    = tpHead;
                        this.tpHead = tpHead._next;
                        this.tpCount--;
                        if (this.tpCount == 0)
                        {
                            this.tpTail = null;
                            ThreadPool.ClearAppDomainRequestActive();
                        }
                    }
                    Monitor.Exit(this.tpSync);
                }
            }
            return(callback);
        }