public void Dispose() { if (!_disposed) { Server.UnregisterClient(this); _state = ClientState.Closed; if (_stream != null) { _stream.Dispose(); _stream = null; } if (TcpClient != null) { TcpClient.Close(); TcpClient = null; } Reset(); _disposed = true; } }