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

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

private PrePush ( object expectedOwner ) : void
expectedOwner object
Результат void
        internal void PrePush(object expectedOwner) {
            lock (this) {
                //3 // The following tests are retail assertions of things we can't allow to happen.
                if (null == expectedOwner) {
                    if (null != m_Owner && null != m_Owner.Target)
                        throw new InternalException();      // new unpooled object has an owner
                } else {
                    if (null == m_Owner || m_Owner.Target != expectedOwner)
                        throw new InternalException();      // unpooled object has incorrect owner
                }

                m_PooledCount++;

                if (1 != m_PooledCount)
                    throw new InternalException();          // pushing object onto stack a second time

                if (null != m_Owner)
                    m_Owner.Target = null;
            }
        }

Usage Example

Пример #1
0
        private PooledStream Create(CreateConnectionDelegate createConnectionCallback)
        {
            PooledStream stream = null;

            try
            {
                stream = createConnectionCallback(this);
                if (stream == null)
                {
                    throw new InternalException();
                }
                if (!stream.CanBePooled)
                {
                    throw new InternalException();
                }
                stream.PrePush(null);
                lock (this.m_ObjectList.SyncRoot)
                {
                    this.m_ObjectList.Add(stream);
                    this.m_TotalObjects = this.m_ObjectList.Count;
                }
            }
            catch (Exception exception)
            {
                stream          = null;
                this.m_ResError = exception;
                this.Abort();
            }
            return(stream);
        }
All Usage Examples Of System.Net.PooledStream::PrePush