private void AcceptClients() { while (!IsDone()) { try { var client = MasterServer.AcceptTcpClient(); if (client.Connected) { var ch = new ConnectionHandler(client, this); Task.Factory.StartNew(() => { ch.HandleConnection(); }); ConnectClients.Add(ch); Console.WriteLine("Client added and is now awaiting work: " + client.GetHashCode()); } } catch (Exception) { Console.WriteLine("Reached the end of dictionary"); } } }