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

Activate() защищенный Метод

protected Activate ( object owningObject, bool async, int timeout, GeneralAsyncDelegate asyncCallback ) : bool
owningObject object
async bool
timeout int
asyncCallback GeneralAsyncDelegate
Результат bool
        protected bool Activate(object owningObject, bool async, int timeout, GeneralAsyncDelegate asyncCallback)
        {
            GlobalLog.Assert(owningObject == Owner || Owner == null, "PooledStream::Activate|Owner is not the same as expected.");
            try {
                if (m_Initalizing) {
                    IPAddress address = null;
                    m_AsyncCallback = asyncCallback;
                    Socket socket = ServicePoint.GetConnection(this, owningObject, async, out address, ref m_AbortSocket, ref m_AbortSocket6, timeout);
                    if (socket != null) {
                        m_NetworkStream.InitNetworkStream(socket, FileAccess.ReadWrite);
                        m_ServerAddress = address;
                        m_Initalizing = false;
                        m_JustConnected = true;
                        m_AbortSocket = null;
                        m_AbortSocket6 = null;
                        return true;
                    }
                    return false;
                }
                else if (async && asyncCallback != null)
                {
                    asyncCallback(owningObject, this);
                }
                return true;
            } catch {
                m_Initalizing = false;
                throw;
            }
        }

Same methods

PooledStream::Activate ( object owningObject, GeneralAsyncDelegate asyncCallback ) : bool

Usage Example

Пример #1
0
        internal PooledStream GetConnection(object owningObject, GeneralAsyncDelegate asyncCallback, int creationTimeout)
        {
            int          num;
            PooledStream pooledStream = null;
            bool         continueLoop = true;
            bool         flag2        = asyncCallback != null;

            if (this.m_State != State.Running)
            {
                throw new InternalException();
            }
            Interlocked.Increment(ref this.m_WaitCount);
            WaitHandle[] waitHandles = this.m_WaitHandles;
            if (!flag2)
            {
                while ((pooledStream == null) && continueLoop)
                {
                    num          = WaitHandle.WaitAny(waitHandles, creationTimeout, false);
                    pooledStream = this.Get(owningObject, num, ref continueLoop, ref waitHandles);
                }
            }
            else
            {
                num = WaitHandle.WaitAny(waitHandles, 0, false);
                if (num != 0x102)
                {
                    pooledStream = this.Get(owningObject, num, ref continueLoop, ref waitHandles);
                }
                if (pooledStream == null)
                {
                    AsyncConnectionPoolRequest asyncRequest = new AsyncConnectionPoolRequest(this, owningObject, asyncCallback, creationTimeout);
                    this.QueueRequest(asyncRequest);
                }
            }
            if (pooledStream != null)
            {
                if (!pooledStream.IsInitalizing)
                {
                    asyncCallback = null;
                }
                try
                {
                    if (!pooledStream.Activate(owningObject, asyncCallback))
                    {
                        pooledStream = null;
                    }
                    return(pooledStream);
                }
                catch
                {
                    this.PutConnection(pooledStream, owningObject, creationTimeout, false);
                    throw;
                }
            }
            if (!flag2)
            {
                throw new InternalException();
            }
            return(pooledStream);
        }
All Usage Examples Of System.Net.PooledStream::Activate