System.Net.ConnectionPool.Create C# (CSharp) Method

Create() private method

Creates a new PooledStream, performs checks as well on the new stream

private Create ( CreateConnectionDelegate createConnectionCallback ) : PooledStream
createConnectionCallback CreateConnectionDelegate
return PooledStream
        private PooledStream Create(CreateConnectionDelegate createConnectionCallback) {
            GlobalLog.Enter("ConnectionPool#" + ValidationHelper.HashString(this) + "::Create");
            PooledStream newObj = null;

            try {
                newObj = createConnectionCallback(this);

                if (null == newObj)
                    throw new InternalException();    // Create succeeded, but null object

                if (!newObj.CanBePooled)
                    throw new InternalException();    // Create succeeded, but non-poolable object

                newObj.PrePush(null);

                lock (m_ObjectList.SyncRoot) {
                    m_ObjectList.Add(newObj);
                    m_TotalObjects = m_ObjectList.Count;
                }

                GlobalLog.Print("Create pooledStream#"+ValidationHelper.HashString(newObj));
            }
            catch(Exception e)  {
                GlobalLog.Print("Pool Exception: " + e.Message);

                newObj = null; // set to null, so we do not return bad new object
                // Failed to create instance
                m_ResError = e;
                Abort();
            }
            catch {
                GlobalLog.Print("Pool Exception: Non-CLS Compliant Exception");

                newObj = null; // set to null, so we do not return bad new object
                // Failed to create instance
                m_ResError = new Exception(SR.GetString(SR.net_nonClsCompliantException));
                Abort();
            }
            GlobalLog.Leave("ConnectionPool#" + ValidationHelper.HashString(this) + "::Create",ValidationHelper.HashString(newObj));
            return newObj;
        }