여러 비동기 http 요청을 기다리는 방법에 대해 질문하고 싶습니다.여러 비동기 http 요청을 기다리는 방법
내 코드는 다음과 같다 :
public void Convert(XDocument input, out XDocument output)
{
var ns = input.Root.Name.Namespace;
foreach (var element in input.Root.Descendants(ns + "a"))
{
Uri uri = new Uri((string)element.Attribute("href"));
var wc = new WebClient();
wc.OpenReadCompleted += ((sender, e) =>
{
element.Attribute("href").Value = e.Result.ToString();
}
);
wc.OpenReadAsync(uri);
}
//I'd like to wait here until above async requests are all completed.
output = input;
}
용량의 사람이 이것에 대한 해결책을 알아?