private static void DoCleanup(MyServer server) { foreach (var device in server._devices.Select(x => x.Value).Where(x => !x.Connected)) { server._logger.LogInformation("Device {Device} disconnected", device.Id); server.DisposeClient(device); } }