private async Task StartUpdatingIps(UpdateIpDetails update) { /// End the process if (update.Ips.Count() == 0) { _memory.RemoveItem("Update"); return; } List <IPDetails> result; /// Take 10 and continue if there are plenty left if (update.Ips.Count() >= 10) { HashSet <string> ipToProcess = update.Ips.Take(10).ToHashSet(); result = await _ipInfoProvider.GetDetailsForMany(ipToProcess); UpdateMultipleIps(result, ipToProcess); update.Ips = update.Ips.Skip(10).ToHashSet(); update.Completed += 10; _memory.InsertToMemory("IpUpdate", update); await StartUpdatingIps(update).ConfigureAwait(false); return; } /// Take the last items and finish result = await _ipInfoProvider.GetDetailsForMany(update.Ips).ConfigureAwait(false); UpdateMultipleIps(result, update.Ips); _memory.RemoveItem("Update"); }