I am trying to get a ProgressDialog to show in my app, but it never shows up. I have tried multiple solutions, but none of them work. I was wondering if anyone had any working solutions or knew what I was doing wrong in my code? Thanks in advance for the help.
Basically, I am trying to upload user information to a database, and I have an asynchronous method to send the information and get a response. But I need to wait for the response because if the username is already in the database, the user needs to know. I am trying to use a progress dialog to help stop the code from continuing.
Here is the code I am currently working with:
Progress = ProgressDialog(this); Progress.SetTitle("Please wait..."); Progress.SetMessage("Contacting server."); Progress.Indeterminate = true; Progress.SetProgressStyle(ProgressDialogStyle.Spinner); Progress.Show(); Task.Run(async () => { await RemoteDB.AddOrUpdateUser(thisUser); });
And then in my Remote Database class, I have an event which fires that closes the Progress Dialog with Progress.Dismiss();
I have also tried this solution:
Progress = new ProgressDialog(this); Progress.SetTitle("Please wait..."); Progress.SetMessage("Contacting server."); Progress.Indeterminate = true; Progress.SetProgressStyle(ProgressDialogStyle.Spinner); Progress.Show(); new Thread(new ThreadStart(async delegate { await RemoteDB.AddOrUpdateUser(thisUser); })).Start();
And I have tried starting the ProgressDialog with this code too:
Progress = ProgressDialog.Show(this, "Please wait...", "Contacting server.", true, false);
Where true is for setting indeterminate and false is for setting cancelable.