public static void MessageHandler(Server serv, Socket socket) { string message = ""; while (true) { message = Server.ReceiveMessage(serv, socket); foreach (var client in serv.ClientList) { if (client.Key == socket) { continue; } serv.SendMessage(client.Key, serv.ClientList[socket], message); } } serv.ThreadList[socket].Abort(); serv.ThreadList.Remove(socket); serv.StopWorking(); }