Мой код примерно такой:
Код: Выделить всё
List tasks = new List();
items..Select(i => tasks.Add(ProcessItem(i));
try
{
await Task.WhenAll(taskList.ToArray());
}
catch (Exception ex)
{
}
Код: Выделить всё
await SendRequestAsync(..blah). Это выглядит так:
private async Task SendRequestAsync(HttpRequestMessage request, CancellationToken token)
{
token.ThrowIfCancellationRequested();
var response = await HttpClient
.SendAsync(request: request, cancellationToken: token).ConfigureAwait(continueOnCapturedContext: false);
token.ThrowIfCancellationRequested();
return await Response.BuildResponse(response);
}
Стоит отметить, что ProcessItem может выполнять от 1 до 4 вызовов API в зависимости от элемента.
Подробнее здесь: https://stackoverflow.com/questions/354 ... t-requests
Мобильная версия