I am using ProgressDialog to show loading whenever user clicks on any menu, and it works fine. But when the user clicks twice on menus, ProgressDialog not stopping, it's running endlessly.
How can I solve this issue?
This is my code structure:
async void Grid_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
{
_pbr = Utilities.ProgressBar(this, "b").Show();
switch (e.Position)
{
case 0:
var result = await objHw.GetHomework(userid,log.LogInOrganizationID);
if (resultA.Any())
{
//code
}
else
{
_pbr.Hide();
Toast.MakeText(this, "Homework not available.", ToastLength.Short).Show();
}
_pbr.Hide();
break;
case 1:
case 2:
}
}
Utilities.ProgressBar method:
public static ProgressDialog ProgressBar(Context context, string position)
{
var pbr = new ProgressDialog(context);
pbr.SetCancelable(false);
pbr.Indeterminate = true;
pbr.SetProgressStyle(ProgressDialogStyle.Spinner);
switch (position.ToLower())
{
case "c":
pbr.Window.SetGravity(GravityFlags.Center);
break;
case "b":
pbr.Window.SetGravity(GravityFlags.Bottom);
break;
}
pbr.SetMessage("please wait..");
return pbr;
}
Loading...
