Show spinner when load or save with custom method

Hi,

I have an app that make many tasks on server method when load or save a complex data structure. I want to avoid user click twice submit button and show a spinner or some visual element that inform user saving or loading task is in progress. Can you suggest a way to accomplish this?

Thanks!

1 Like

Hi @Carlos_Carminati,

You can do the following:

  1. Set a page property e.g. isLoading to true just before invoking the custom method.
  2. Set it back to false in the Then event of the custom method.
  3. Set the Visible property of some component that will display the loading (Image, Label or anything) to ${isLoading}.

2 Likes

If you add, await Task.Delay(1) before and, this loading will work to Radzen Blazor.

public async Task YourTask()
{
    try
    {
        isLoadingSpinner = true;
        await Task.Delay(1);
            
       // Your task to loding....
        isLodingSpinner = false;
        await Task.Delay(1);
    }
    catch (Exception ex)
    {
        isLodingSpinner = false;
        NotificationService.Notify(new NotificationMessage(){ Severity = NotificationSeverity.Error,Summary  $"Error",Detail = $"error message!" });
    };
}