OpenPrinterDialog fails to open?

I have this code, in an app written in Xojo 2017r3:

gPrinter=OpenPrinterDialog(gPrinterSetup)

By the time we get to here, gPrinterSetup <>nil and has the info for the current printer.

In one part of my app, the printer dialog opens and waits for user input, as it always has, but in another part, the dialog flashes on the screen for a moment and then closes without any user interaction at all, at which point the code goes ahead and prints as if the user had pressed OK.

What would make the dialog not wait for user input?

I’ve since discovered that the same thing can happen with PageSetupDialog, as in this code snippet:

if gPrinterSetup.PageSetupDialog then

…which also skips right through the dialog.

The obvious but hard-to-explain-why suggestion is an incorrect or corrupted printersetup string.

The hard part is knowing when it’s incorrect or corrupted… I could recreate a new one every time, or maybe just not pass the setup string, I’m not restoring from a previous session.

I do that.
Start with nil.
First time printing, remember the setup.
Assume its valid for any future printing until the app closes.
I dont trust a saved setup string.

FWIW, I solved the problem by doing OpenPrinterDialog in a separate method called by a timer.

It uses GUI so it will at least not work from a thread.
And opening a window may not always permitted in an event handler.