private void OnClientDisconnected(object sender, ResponseReceiverEventArgs e) { // Remove the client from the listbox. // Note: we can directly access the listbox because we set threading mode of // InputChannelThreading to the main UI thread. //ConnectedClientsListBox.Items.Remove(e.ResponseReceiverId); Client temp = null; foreach (Client client in clients) { if (client.id == e.ResponseReceiverId) { client.Disconnect(); temp = client; SenDisconnectedClient?.Invoke(sender, e); break; } } if (temp != null) { clients.Remove(temp); } }
public void Disconnect(string aClientId) { if (!string.IsNullOrEmpty(aClientId)) { myReceiver.AttachedDuplexInputChannel.DisconnectResponseReceiver(aClientId); Client temp = GetClient(aClientId); if (temp != null) { clients.Remove(temp); ResponseReceiverEventArgs e = new ResponseReceiverEventArgs(aClientId, ""); SenDisconnectedClient?.Invoke(null, e); } } }
public void btnDisconnect_Click(object sender, EventArgs e) { SenDisconnectedClient?.Invoke(sender, e); //do implementacji }