我有这段代码,我如何将其转换为异步,我尝试用readtoend
更改readtoendasync
,但是......
public HttpWebResponse smethod_1(ref HttpWebRequest httpWebRequest_0)
{
HttpWebResponse httpWebResponse;
try
{
httpWebRequest_0.Method = "GET";
httpWebResponse = (HttpWebResponse)httpWebRequest_0.GetResponse();
}
catch (Exception ex)
{
ProjectData.SetProjectError(ex);
httpWebResponse = (HttpWebResponse)null;
ProjectData.ClearProjectError();
}
return httpWebResponse;
}
public string method_0(ref HttpWebRequest httpWebRequest0)
{
return new StreamReader(this.smethod_1(ref httpWebRequest0).GetResponseStream(), Encoding.UTF8, true).ReadToEnd();
}
public string Smethod0(ref HttpWebRequest httpWebRequest0)
{
return new StreamReader(this.smethod_1(ref httpWebRequest0).GetResponseStream(), Encoding.UTF8, true).ReadToEnd();
}
我也尝试过
await httpWebRequest0_1.GetResponseAsync();
但是它返回我错误