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

Get a ProgressDialog to show.

$
0
0

I cannot get a ProgressDialog to show in a VS2010 project. I start a new project and leave all of the defaults and put this into the button click event:

  ProgressDialog progress = new ProgressDialog(this);
  progress.Indeterminate = true;
  progress.SetProgressStyle(ProgressDialogStyle.Spinner);
  progress.SetMessage("Contacting server. Please wait...");
  progress.SetCancelable(false);
  progress.Show();
  //progress.Dismiss();

This will display the ProgressDialog just fine. Now if I try anything after the Show(), the dialog is not shown. This is what I've tried:

  // Does not show
  progress.Show();
  System.Threading.Thread.Sleep(5000);
  progress.Dismiss();

  // Does not show
  progress.Show();
  new Thread(new ThreadStart(() =>
  {
    System.Threading.Thread.Sleep(5000);
    progress.Dismiss();
  })).Start();

  // Does not show
  progress.Show();
  new Thread(new ThreadStart(() =>
  {
    RunOnUiThread(() => { System.Threading.Thread.Sleep(5000); }); 
    progress.Dismiss();
  })).Start();

In all instances it does the Sleep for 5 seconds, but the ProgressDialog does not show. Anything else I should try? I will be calling a REST web service where the Sleep is and wanted to provide some feedback to the user.

Thanks.


Viewing all articles
Browse latest Browse all 204402

Trending Articles



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