2013-09-06 1 views
4

Je suis nouveau à HttpClient. Mon code ci-dessous dit toujours "WaitingForActivation" dans le statut. S'il vous plaît aiderHttpClient GetAsync dit toujours 'WaitingForActivation'

private static async Task<HttpResponseMessage> MakeCall() 
    { 
     var httpclient = new HttpClient(); 

     var response = await httpclient.GetAsync("http://localhost:60565/Subscribers"); 

     return response; 
    } 

Répondre

1

C'est normal. Juste await la tâche renvoyée pour attendre (asynchrone) pour terminer. Vous pouvez trouver mon intro to async utile.

3

Alternativement, si vous ajoutez environnement est synchrone .Result, comme ceci:

GetAsync("http://localhost:60565/Subscribers").Result; 
Questions connexes