executeAsModal() equivalent for InDesign?

I’m currently developing a plugin that generates a bus schedule timetable. When the user presses the “Generate Timetable” button, I’d like a modal with a progress bar to steal focus while the script runs, similar to Photoshop’s executeAsModal().

I’m aware of app.doScript() which @pklaschka described in this post, which runs the script without a modal but adds the entire script to the undo history, which is nice.

I also tried calling .uxpShowModal() on a <dialog> before the script runs, but this always ends up with the modal appearing after the script has finished.

Any ideas?