I have a simple method shown below. How can I convert it to async?
public string Smethod0(HttpWebRequest httpWebRequest0)
{
return new StreamReader(Smet
You can make it async by using async/await mechanism:
public async Task Smethod0(HttpWebRequest httpWebRequest0)
{
return await new StreamReader(Smethod_1(httpWebRequest0).GetResponseStream(),
Encoding.UTF8, true).ReadToEndAsync();
}
Also see I'm using ReadToEndAsync() in stead of ReadToEnd().
And Steve is right, you'll have to dispose the stream first before returning the result.