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

Lists in Python -

android - can not access to progress bar in an other activity -

java - Vaadin 7 Pass Data Between Views -