Как: выполнять несколько веб-запросов параллельно с помощью async и await (C#)
и нашел:
Код: Выделить всё
private async Task CreateMultipleTasksAsync()
{
// Declare an HttpClient object, and increase the buffer size. The
// default buffer size is 65,536.
HttpClient client =
new HttpClient() { MaxResponseContentBufferSize = 1000000 };
// Create and start the tasks. As each task finishes, DisplayResults
// displays its length.
Task download1 =
ProcessURLAsync("http://msdn.microsoft.com", client);
Task download2 =
ProcessURLAsync("http://msdn.microsoft.com/library/hh156528(VS.110).aspx", client);
Task download3 =
ProcessURLAsync("http://msdn.microsoft.com/library/67w7t67f.aspx", client);
// Await each task.
int length1 = await download1;
int length2 = await download2;
int length3 = await download3;
int total = length1 + length2 + length3;
// Display the total count for the downloaded websites.
resultsTextBox.Text +=
string.Format("\r\n\r\nTotal bytes returned: {0}\r\n", total);
}
Подробнее здесь: https://stackoverflow.com/questions/480 ... -and-await
Мобильная версия