c# - getting HttpResponseMessage from a Task<HttpResponseMessage> -
inside httpclient using statement need unwrap somewhere httpresponsemessage.
using (httpclient client = new httpclient()) { client.defaultrequestheaders.authorization = new authenticationheadervalue("basic", authuser); task<httpresponsemessage> m = client.getasync(url); // httpresponsemessage msg = ??? task.wait(); return task.result; } my question is: how can httpresponsemessage line
task<httpresponsemessage> m = client.getasync(url);
you should await task:
httpresponsemessage m = await client.getasync(url); in order that, calling method needs marked async.
Comments
Post a Comment