Windows phone 7 将代码c#sync httprequest转换为async
我对这些代码有一个问题,我需要将这个Json httprequest转换为一个异步方法,以便在WP7 C#应用程序中使用它,下面是代码,我真的需要这方面的帮助 它显示以下语句中的错误: 1) myReq.ContentLength=postData.Length;-->ContentLength不包含此类型的方法 2) webresponse=(HttpWebResponse)myReq.GetResponse();-->是一种同步方法,不包含在httpresponse metod中 3) StreamWriter stOut=newstreamwriter(myReq.GetRequestStream(),System.Text.Encoding.ASCII);-->是一种同步方法,不包含在httpresponse metod中 4) GoogleCell cell=JsonConvert.DeserializeObject(响应);-->方法重载或缺少转换…并且转换发生在第三个错误Windows phone 7 将代码c#sync httprequest转换为async,windows-phone-7,c#-4.0,silverlight-4.0,asynchronous,Windows Phone 7,C# 4.0,Silverlight 4.0,Asynchronous,我对这些代码有一个问题,我需要将这个Json httprequest转换为一个异步方法,以便在WP7 C#应用程序中使用它,下面是代码,我真的需要这方面的帮助 它显示以下语句中的错误: 1) myReq.ContentLength=postData.Length;-->ContentLength不包含此类型的方法 2) webresponse=(HttpWebResponse)myReq.GetResponse();-->是一种同步方法,不包含在httpresponse metod中 3) St
/// internal google cell info to post
public GoogleCell GetCellInfo(string lac, string mnc, string mcc, string cellID)
{
HttpWebRequest myReq = (HttpWebRequest)WebRequest.Create("https://www.google.com/loc/json");
myReq.Method = "POST";
myReq.ContentType = "application/jsonrequest";
string postData = "{\"cell_towers\": [{\"location_area_code\": \"" + lac + "\", \"mobile_network_code\": \"" + mnc + "\", \"cell_id\": \"" + cellID + "\", \"mobile_country_code\": \"" + mcc + "\"}], \"version\": \"1.1.0\", \"request_address\": \"true\"}";
myReq.ContentLength = postData.Length;
StreamWriter stOut = new StreamWriter(myReq.GetRequestStream(), System.Text.Encoding.ASCII);
stOut.Write(postData);
stOut.Close();
HttpWebResponse webresponse;
webresponse = (HttpWebResponse)myReq.GetResponse();
Encoding enc = System.Text.Encoding.UTF8;
StreamReader loResponseStream = new StreamReader(webresponse.GetResponseStream(), enc);
string Response = loResponseStream.ReadToEnd();
loResponseStream.Close();
webresponse.Close();
GoogleCell cell = JsonConvert.DeserializeObject(Response);
return cell;
}
}
在WCF中转换的完整类在上仍有错误 反序列化对象(响应)