System.Net.PooledStream.PostPop C# (CSharp) Метод

PostPop() приватный Метод

private PostPop ( object newOwner ) : void
newOwner object
Результат void
        internal void PostPop (object newOwner) {
            GlobalLog.Assert(!IsEmancipated, "Pooled object not in pool.");
            GlobalLog.Assert(CanBePooled, "Pooled object is not poolable.");


            lock (this) {
                if (null == m_Owner)
                    m_Owner = new WeakReference(newOwner);
                else {
                    if (null != m_Owner.Target)
                        throw new InternalException();        // pooled connection already has an owner!

                    m_Owner.Target = newOwner;
                }

                m_PooledCount--;

                if (null != Pool) {
                    if (0 != m_PooledCount)
                        throw new InternalException();  // popping object off stack with multiple pooledCount
                } else {
                    if (-1 != m_PooledCount)
                        throw new InternalException();  // popping object off stack with multiple pooledCount
                }
            }
        }

Usage Example

Пример #1
0
        private PooledStream Get(object owningObject, int result, ref bool continueLoop, ref WaitHandle[] waitHandles)
        {
            PooledStream fromPool = null;
            int          num2     = result;

            switch (num2)
            {
            case 1:
            {
                int num = Interlocked.Decrement(ref this.m_WaitCount);
                continueLoop = false;
                Exception resError = this.m_ResError;
                if (num == 0)
                {
                    this.CancelErrorCallback();
                }
                throw resError;
            }

            case 2:
                try
                {
                    continueLoop = true;
                    fromPool     = this.UserCreateRequest();
                    if (fromPool != null)
                    {
                        fromPool.PostPop(owningObject);
                        Interlocked.Decrement(ref this.m_WaitCount);
                        continueLoop = false;
                        return(fromPool);
                    }
                    if (((this.Count >= this.MaxPoolSize) && (this.MaxPoolSize != 0)) && !this.ReclaimEmancipatedObjects())
                    {
                        waitHandles = new WaitHandle[] { this.m_WaitHandles[0], this.m_WaitHandles[1] };
                    }
                    return(fromPool);
                }
                finally
                {
                    this.CreationMutex.ReleaseMutex();
                }
                break;

            default:
                if (num2 == 0x102)
                {
                    Interlocked.Decrement(ref this.m_WaitCount);
                    continueLoop = false;
                    throw new WebException(NetRes.GetWebStatusString("net_timeout", WebExceptionStatus.ConnectFailure), WebExceptionStatus.Timeout);
                }
                break;
            }
            Interlocked.Decrement(ref this.m_WaitCount);
            fromPool     = this.GetFromPool(owningObject);
            continueLoop = false;
            return(fromPool);
        }
All Usage Examples Of System.Net.PooledStream::PostPop