I have a simple C# app which must send one HTTP GET
request to many servers and get a response from each of them on button click. Also I need it to perform some operations after all servers responded. So, I can use HttpWebRequest
class with async operations and count total responses number in every callback. But maybe there's a special library for advanced callback flow control, like Async
in JavaScript for example?
相关问题
- Angular RxJS mergeMap types
- Sorting 3 numbers without branching [closed]
- Graphics.DrawImage() - Throws out of memory except
- Why am I getting UnauthorizedAccessException on th
- 求获取指定qq 资料的方法
You can call
HttpWebRequest.GetResponseAsync
to obtainTask<WebResponse>
. Then callTask.WhenAll
to get another task, which ends when all other tasks end. To wait synchronously for all tasks, useTask.WaitAll
.Example:
Useful links: Task Parallel Library, Asynchronous Programming with async and await
Also, I believe, System.Net.Http.HttpClient is a more convenient class for making HTTP calls.