I'm using Task.WhenAll on a collection of Task HttpResponseMessage. I want to add a Task.Delay between each request to rate limit the calls to the API.
Obviously my list is a strongly typed List of Task<HttpResponseMessage>
and a Task.Delay is just a Task.
Is there a way to make this handle both or do I need to rethink my implementation?
foreach (var x in items)
{
requestList.Add(MakeHttpClientCall(x)); <== requestList = List<Task<HttpResponseMessage>>
// want to add a Task.Delay here e.g.
requestList.Add(Task.Delay(4)) etc
}
Task allTasks = Task.WhenAll(statNumberList);
try
{
await allTasks;
}
I've tried playing around with lists of Task and casting but no luck so far. Hope this makes sense! Thanks