我想编写一个处理我的 WebClient-Tasks 并返回其结果的类。
问题是,异步下载不会让一个简单的return
处理:
public void checkAvailability()
{
WebClient wc = new WebClient();
wc.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
wc.UploadStringCompleted += wc_UploadStringCompleted;
wc.UploadStringAsync(new Uri("http://random.php"), "?lookup=10");
//return parsed content from wc_UploadStringCompleted
}
private void wc_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
// do something
}
我怎样才能把它们放在一起让它工作?