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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -