static Func <IPAddress[]> CreateIp(string hostOrIp, params string[] hostOrIps) { IEnumerable <IPAddress> ips = new IPAddress[] { }; Array.ForEach(hostOrIps.Append(hostOrIp).ToArray(), (item) => { ips = ips.Concat(Dns.GetHostAddresses(item)); }); var queue = new ConcurrentQueue <IPAddress>(ips); return(() => { IPAddress ip; if (queue.TryDequeue(out ip)) { queue.Enqueue(ip); } return queue.ToArray(); }); }