The Dialog phase was unexpectedly (and apparently randomly) exiting during program execution. On monitoring the return value from Dialog() on a simple test program, I see the value of 18446744073709551615 rather than -1 (the 64-bit unsigned int representation of the same value). The return value from Dialog() doesn't appear to be explicitly defined in the documentation, but DoEvents() returns the same value, so the suggested equivalent of
while(Win32::GUI::DoEvents() != -1) {};
doesn't work.
This happens on Windows 11, perl 5.40.2 and Win32-GUI-1.14, though I tested back as far as perl5.16 and GUI-1.13 with the same results