public TcpClientConnection(string ip, int port) { this.ip = ip; this.port = port; this.client = new TCPClient(); client.ConnectCompleted += Client_ConnectCompleted; client.DisconnectCompleted += Client_DisconnectCompleted; client.ReceiveCompleted += Client_ReceiveCompleted; }
private bool disposedValue = false; // 要检测冗余调用 protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { if (client != null) { client.Dispose(); } } client = null; disposedValue = true; } }