Get applet to ignore 'on reopen' requests while a dialog box is open?

As the title says. Is this possible? Does anyone know how?

Long version:

What ends up happening is my users click on the applet icon in the Dock to bring it back to the front after doing something else.

While a dialog is active in the applet, that’s all fine. But since I have a reopen handler (which provides necessary functionality and isn’t removable), when they click on the applet icon 3 or 4 times when switching back and forth between all their apps (as one would in normal use), as soon as they’re done with the applet, the reopen handler runs that many times in a row, which confuses them (it would annoy me too).

I’m not at all confused about why it’s happening, but I’m absolutely confused at Apple’s reasoning here as to why AppleScript applets were designed like this.

Why can’t there at least be an option to block ‘on reopen’ clicks from adding to this virtual queue while the applet is doing something else? I’ve tried clunky solutions to do just this, but they don’t work. Any suggestions?

What is your on reopen handler doing, and can you share some of your attempts, no matter how clunky ?

I recall an issue like this a few years ago.

I believe I put a global in the script called lastFinishedTime

Then the open handler would have:

if theTimeNow - lastFinishTime < 120 then return

(I believe it was a stay open applet.)