Forum Xamarin.Android

ProgressDialog shows up after content is loaded

Hi All, I have tried a lot but in vain. My ProgressDialog shows up on the screen after the content is loaded. Please help.

// Method in MainActitvity.cs

    public void MenuListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        ProgressDialog pDialog = new ProgressDialog(this);
        pDialog.SetMessage("Downloading content. Please wait ... ");
     pDialog.Indeterminate = false;



       LoadContent(); // Data refresh


Though it must execute in sequence, LoadContent() is executed first and then the dialog comes up.


Best Answers

  • amitchaudhary.5913amitchaudhary.5913 US ✭✭
    Accepted Answer

    Thanks a lot. It did work.


  • SAthukoraleSAthukorale USMember ✭✭
    edited May 2017

    Am I correct in assuming that you are doing whatever you do in LoadContent in the same thread as your UI. If so you are blocking your UI thread, and that may be the reason behind this behavior. Consider moving that segment to a different thread. For example take the following pseudo code :

    ThreadPool.QueueUserWorkItem(() => { LoadContent(); Activity?.RunOnUIThread(() => { pDialog.Dismiss(); }); });
  • amitchaudhary.5913amitchaudhary.5913 USMember ✭✭
    Accepted Answer

    Thanks a lot. It did work.

Sign In or Register to comment.