BF2Statistics.Gamespy.Net.GamespyTcpSocket.Dispose C# (CSharp) Method

Dispose() public method

Releases all Objects held by this socket. Will also shutdown the socket if its still running
public Dispose ( ) : void
return void
        public void Dispose()
        {
            // no need to do this again
            if (IsDisposed) return;
            IsDisposed = true;

            // Shutdown sockets
            if (IsListening)
                ShutdownSocket();

            // Dispose all AcceptPool AysncEventArg objects
            while (SocketAcceptPool.Count > 0)
                SocketAcceptPool.Pop().Dispose();

            // Dispose all ReadWritePool AysncEventArg objects
            while (SocketReadWritePool.Count > 0)
                SocketReadWritePool.Pop().Dispose();

            // Dispose the buffer manager after disposing all EventArgs
            BufferManager.Dispose();
            MaxConnectionsEnforcer.Dispose();
            Listener.Dispose();
        }