How get result back from async method ?
async Task<string> Get(string Url) { HttpClient httpClient = new HttpClient(); httpClient.MaxResponseContentBufferSize = 10485760; httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"); HttpResponseMessage response = await httpClient.GetAsync(Url); return await response.Content.ReadAsStringAsync(); } call the method
var a = Get(address).Result; Outbox.Text = a; when try to get result, in output winodow i got "The thread 0xdf4 has exited with code 0 (0x0)"
and nothing happend
but i can get result by this way
async Task Get(string Url) { HttpClient httpClient = new HttpClient(); httpClient.MaxResponseContentBufferSize = 10485760; httpClient.DefaultRequestHeaders.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)"); HttpResponseMessage response = await httpClient.GetAsync(Url); Outbox.Text = response.Content.ReadAsStringAsync().Result; } and call the method by this way
var a = Get(address); i try this code on windows phone 8.1. thanks.