private void onAccepted(TcpClient tcpClient) { SocketProcessor processor = new SocketProcessor(tcpClient, logHelper); processor.Disconnected += new EventHandler(processor_Disconnected); processor.Start(); lock (this._socketProcessors) { this._socketProcessors.Add(processor); } onConnected(); }
void processor_Disconnected(object sender, EventArgs e) { SocketProcessor p = sender as SocketProcessor; p.Disconnected -= processor_Disconnected; lock (this._socketProcessors) { if (this._socketProcessors.Contains(p)) { this._socketProcessors.Remove(p); } } onDisconnected(); }