public async Task<IEnumerable<UserDto>> GetUsersInParallelInWithBatches(IEnumerable<int> userIds)
{
var tasks = new List<Task<IEnumerable<UserDto>>>();
var batchSize = 100;
int numberOfBatches = (int)Math.Ceiling((double)userIds.Count() / batchSize);
for (int i = 0; i < numberOfBatches; i++)
{
var currentIds = userIds.Skip(i * batchSize).Take(batchSize);
tasks.Add(client.GetUsers(currentIds));
}
return (await Task.WhenAll(tasks)).SelectMany(u => u);
}