asynchronouspaginationdevexpressmauimobile-application

In MUAI, using DXpopup and loading indicator in pagination


I tried several solutions, With Task.Run(()=>) it can be done. UI froze when I try without Task, and it shows spinner only just before page change. There is 2 example, first one is working, but not all pagination work is needed task. I want second one work, just like first one.

  Working one:
if (IsBusy) return;
       Platforms.KeyboardHelper.HideKeyboard();
       GlobalConstants.costantSpinner.Show();
       try
       {           
           GlobalVariables._loginDTO = await Task.Run(() => /*something to do before page change */);
           await Shell.Current.GoToAsync("somePage");
       }
       catch (Exception ex) {/* Display ex*/ }
       finally { IsBusy = false; GlobalConstants.costantSpinner.IsOpen = false; }

It works perfectly when with something to do before Not working one:

  if (IsBusy) return;
            GlobalConstants.costantSpinner.Show();
            try { IsBusy = true; await Shell.Current.GoToAsync(/*Some page*/); }
            catch (Exception ex) {/* Display ex*/}
            finally { IsBusy = false; GlobalConstants.costantSpinner.IsOpen = false; }

Solution

  • If you want the spinner to appear and rotate for a while, you can add a delay before navigating to the other page.

    if (IsBusy) return;
                GlobalConstants.costantSpinner.Show();
                
                try { IsBusy = true;
                      await Task.Delay(1000); // Add this line!
                      await Shell.Current.GoToAsync(/*Some page*/); }
                catch (Exception ex) {/* Display ex*/}
                finally { IsBusy = false; GlobalConstants.costantSpinner.IsOpen = false; }