How to insert a progress bar before a dialog is displayed?

I was troubled by the progress bar recently.
Because one of my dialog has a long opening time, I want to insert a progress bar during the waiting period to show the progress of the dialog opening.
How should I do it? Thanks for all advice！