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.