Forum Xamarin.Android

Announcement:

The Xamarin Forums have officially moved to the new Microsoft Q&A experience. Microsoft Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

To create new threads and ask questions head over to Microsoft Q&A for .NET and get involved today.

Progress Dialog and runOnUiThread not show

Hi,

In my application I want to show a progress dialog while the view is updating.
In my main (OnCreate)

var pd = ProgressDialog.Show(this, "", "Loading....", true);

new Thread(new ThreadStart(delegate

{

RunOnUiThread(() =>

{

//some stuff

});

RunOnUiThread(() => pd.Dismiss());

})).Start();

This code works (the spinner not rotate, but it isn't a big deal)

In another activity, the same code (it's the same, I copy and paste the code, just for try) not show the progress dialog.
The only difference that the code is call by a button in the menu (action bar) and not in OnCreate().

Any ideas?

Posts

  • FZelleFZelle DEMember ✭✭✭

    You seem to have the wrong concept in mind.

    If you do a RunOnUiThread in a thread, the UI Thread can't work so there is no way that the spinner does anything.

    What do you do that you "need" to use RunOnUiThread?

  • LucaFongaroLucaFongaro USMember ✭✭

    If you do a RunOnUiThread in a thread, the UI Thread can't work so there is no way that the spinner does anything.

    The problem it's not the spinner that not rotate ;-)
    I request for a progress dialog that not appear. :-)

    What do you do that you "need" to use RunOnUiThread?

    I wrote it :-)

    In my application I want to show a progress dialog while the view is updating

    In fact the activity update the view and during this time the user must NOT interact with the app, just wait :-)

  • CheesebaronCheesebaron DKInsider, University mod

    The problem is that you are blocking the UI thread by running something on it with RunOnUiThread() in your Thread. Fix that and the ProgressBar will spin.

Sign In or Register to comment.