Quantcast
Channel: Recent Threads — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 204402

[PCL] HttpClient GetAsync blocked application

$
0
0

Hey all,
It's my first application with Xamarin and I try to develop a cross platform application. I develop a PCL for the webservices and a Android app. When I start my application, just click on a button for start an another Activity (Propositions). But the latter blocked with the black screen and in my debugger I saw my personnal log "response start" but not "response done".

Thx all for your answers.

**Log : **
RefreshDataAsync()
response start
[Mono] [0x9a1ff930] hill climbing, change max number of threads 3
[Mono] [0x9a1ff930] worker finishing
Thread finished: #5

In my application :
List propositionsList = new List();
protected override void OnCreate(Bundle savedInstanceState)
{
base.OnCreate(savedInstanceState);
SetContentView(Resource.Layout.Propositions);
listView = FindViewById(Resource.Id.propositionsList);
propositionsList = new RestService().RefreshDataAsync().Result;
}

**In my RestService : **
public class RestService : IRestService
{
HttpClient client;

    public List<Proposition> Items { get; private set; }

    public RestService()
    {
        client = new HttpClient();
        client.MaxResponseContentBufferSize = 256000;
    }

    public async Task<List<Proposition>> RefreshDataAsync()
    {
        Items = new List<Proposition>();
        string url = "http://127.0.0.1:8080/";
        client.BaseAddress = new Uri(url);

        System.Diagnostics.Debug.WriteLine("response start");
        var response = await client.GetAsync("webservice/rest/proposition/propositions").ConfigureAwait(false);
        System.Diagnostics.Debug.WriteLine("response done");
        if (response.IsSuccessStatusCode)
        {
            var content = await response.Content.ReadAsStringAsync();
            Items = JsonConvert.DeserializeObject<List<Proposition>>(content);
        }

        return Items;
    }

}

Viewing all articles
Browse latest Browse all 204402

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>