Having process delay on extendScript

With the plugin I developed on Adobe UXP, I’m running ExtendScript-based scripts by invoking actions. One of these ExtendScript-based dialog windows performs a renaming operation on Photoshop layers. After this operation is completed, I want to perform another renaming operation without calling the dialogWindow.close() method, but there is a delay in renaming the layers. If I call the dialogWindow.close() method after performing this operation, the renaming process occurs without delay. However, for the sake of reusability, I want to perform these operations without closing the dialog window.

Interestingly, if I manually invoke this ExtendScript-based script from the Scripts section in Photoshop, I can perform the operations exactly as I want without closing the dialog window. Do you have any ideas on this matter?

Could be something about elevated modal state… My advice is to rewrite it into UXP. It could/should save more trouble in long-term.