|
|
|
|
|
by SideburnsOfDoom
4849 days ago
|
|
I suspect that you could so something very similar in C# - GetStringAsync returns a Task<string>, and you don't have to await it right away or one by one. So you can do: var urlTask1 = client.GetStringAsync(url1);
var urlTask2 = client.GetStringAsync(url2);
var firstDone = await Task.WhenAny(new Task[] { urlTask1, urlTask2 });
For the rest of it, see Task.ContinueWith, WhenAny, WhenAll etc. http://msdn.microsoft.com/en-us/library/dd235618.aspxThese also return Task<T> objects that you can work with further or await. I'd be very surprised if you can't do the equivalent, also in a totally non-blocking way. |
|