獲得OpenReadCompleted結果我想從webClient_OpenReadCompleted獲取結果,並且我想在getMethod中獲得響應。但是在這段代碼中,getMehod起作用,只有當getMethod完成時,webClient_OpenReadCompleted才起作用。如何在getMethod中獲得結果?如何從方法
p.s.這一切都在Windows Phone
public string apiUri = "https://api.vk.com/method/";
public string response = "";
public void getMethod(string parameters)
{
var webClient = new WebClient();
webClient.OpenReadCompleted += webClient_OpenReadCompleted;
string uri = apiUri + parameters + "&access_token=" + access_token;
webClient.OpenReadAsync(new Uri(uri));
}
void webClient_OpenReadCompleted(object sender, OpenReadCompletedEventArgs e)
{
XDocument xml = XDocument.Load(e.Result);
response = xml.ToString();
}
public void statusGet(string uid)
{
getMethod("status.get.xml?uid" + uid);
}
我沒有嘗試,但我問一個高級C#開發人員,他建議這樣做: – 2012-07-27 12:35:03