Dialog while calling method

Hello,

I’m trying to generate a dialog whith a progress bar with style “indeterminate-circle” while a method is running.

This is my screen xml:

<layout>
    <progressBar id="loading" width="100%" indeterminate="true" stylename="indeterminate-circle"
                 align="MIDDLE_CENTER"/>
</layout>

The idea is:

1.- show the dialog: openWindow(“popup”, WindowManager.OpenType.DIALOG);
2.- call a method: reloadData(initDate, endDate); (with the dialog still visible)
3.- close the dialog when the method ends.

How can I do this?

If I write this code on my Controller, I get the following result:

1.- call the method reloadData
2.- when the method finish, the dialog is shown.

What I’m doing wrong?

Thank you.

2 Likes

Hi,

You should not perform heavy computations in UI event handlers. Instead you should start an asynchronous operation. Take a look at BackgroundTask API and BackgroundWorkWindow dialog:

https://doc.cuba-platform.com/manual-7.0/background_tasks.html

Thank you. I’ll take a look!

Hi again,

I’ve been taking a look at BackgroundTask API and my problem is solved.

Thank ypu very much!

If your problem is solved do not forget to mark useful comment as a solution:

image