/// <summary>
        /// Read the next network packet from the pipe.  Blocks until a packet is detected or the connection fails.
        /// </summary>
        /// <returns></returns>
        protected NetworkMessage ReadNetworkMessage()
        {
            if (m_NetworkSerializer == null)
            {
                m_NetworkSerializer = new NetworkSerializer();
            }

            var            socketClosed = false;
            NetworkMessage nextPacket;

            do
            {
                //see if we have another packet in the buffer...
                nextPacket = m_NetworkSerializer.ReadNext();

                if (nextPacket == null)
                {
                    //go into a blocking wait on the socket..  we'll loop until we get the whole buffer into the stream.
                    byte[] buffer;
                    var    newDataLength = ReadSocket(out buffer);

                    if (newDataLength == 0)
                    {
                        //this is the signal that the other end shut down the pipe.
                        socketClosed = true;
                    }
                    else
                    {
                        m_NetworkSerializer.AppendData(buffer, newDataLength);
                    }
                }
            } while ((socketClosed == false) && (nextPacket == null));

            return(nextPacket);
        }
        /// <summary>
        /// Release and dispose all of the connection-specific resources
        /// </summary>
        private void DisposeMembers()
        {
            lock (m_Lock)
            {
                SafeDispose(m_PacketWriter);
                m_PacketWriter = null;

                SafeDispose(m_NetworkStream);
                m_NetworkStream = null;

                SafeDispose(m_NetworkSerializer);
                m_NetworkSerializer = null;

                SafeDispose(m_PacketReader);
                m_PacketReader = null;

                SafeDispose(m_PacketStream);
                m_PacketStream = null;
            }
        }