locked
Freeze of my app when i access to an Attribut RRS feed

  • Question

  • User229693 posted

    Hello there,

    i have an problem of performance... :/ !

    This is my code :

    public async Task<bool> login(string email, string password,ActivityIndicator loader)
        {
            var notificator = DependencyService.Get<IToastNotificator>();
            loader.IsVisible = true;
    
            System.Diagnostics.Debug.WriteLine("Login");
            if (email == "" || password == "")
            {
    
    
                await notificator.Notify(ToastNotificationType.Error, 
                    "Oups", "Une erreur est survenue", TimeSpan.FromSeconds(2));
    
            }
    
            else {
    
                await notificator.Notify(ToastNotificationType.Success, 
                    "Chargement", "Verification de votre compte", TimeSpan.FromSeconds(2));
    
    
                APILogin result = await APICustomer.login(email, password);
                await notificator.Notify(ToastNotificationType.Warning, "Test", result.userId, TimeSpan.FromSeconds(2));
            }
    
            return true;
    
    
    }
    

    This code load this : APILogin result = await APICustomer.login(email, password);

    The Method :

        public static async Task<APILogin> login(string _email, string _password)
        {
    
            _password = MD5.GetMd5String(_password);
            string responseString;
    
            _email = noSpaceMore(_email);
            _password = noSpaceMore(_password);
    
            using (HttpClient client = new HttpClient())
            {
    
    
                dynamic dataResponse = await Task.Factory.StartNew(() =>
                {
    
                    string postdataJson = JsonConvert.SerializeObject(new { email = _email, password = _password });
                    var postdataString = new StringContent(postdataJson, new UTF8Encoding(), "application/json");
                    var responseObj = client.PostAsync("URL", postdataString);
                    responseString = responseObj.Result.Content.ReadAsStringAsync().Result;
                    APILogin stuff = JsonConvert.DeserializeObject<APILogin>(responseString);
                    return stuff;
                });
    
                return dataResponse;
            }
    
        }
    

    So, my code works well, not slow or whatever apart when i want to display result.userId... At this moment my application freeze few times ( One seconde but it's not normal )

    at the first, my object was Dynamic but i will want to improve my code, so i have created a specific class for my response.

    if you have any idea... Thanks!

    EDIT : I remove result.userId display and i still have a freeze :/ !

    Monday, June 6, 2016 7:45 PM

Answers

  • User229693 posted

    So if my problem can help anyone, don't you Dynamic variable.... it sucks

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 9, 2016 6:24 PM

All replies

  • User229693 posted

    Oh, i found this in my output !

    [art] Starting a blocking GC Explicit [art] Explicit concurrent mark sweep GC freed 2552(169KB) AllocSpace objects, 1(184KB) LOS objects, 27% free, 43MB/59MB, paused 244us total 12.725ms [Mono] GCOLDBRIDGE num-objects 38 numhashentries 39 sccs size 39 init 0.00ms df1 0.09ms sort 0.00ms dfs2 0.27ms setup-cb 0.03ms free-data 0.03ms links 3/3/3/1 dfs passes 80/42 [Mono] GC_MINOR: (Nursery full) pause 25.15ms, total 25.24ms, bridge 0.00ms promoted 3008K major 3008K los 469K

    How correct this ? :(

    Monday, June 6, 2016 9:02 PM
  • User229693 posted

    So if my problem can help anyone, don't you Dynamic variable.... it sucks

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, June 9, 2016 6:24 PM