Publish-UiEvent only enters the delivery-wait loop under $script:UiServer, and Show-ProgressWindow returns before the WinForms card is built whenever the browser shim is up, so $script:Ui is always null there. The DoEvents call could never run; the 50ms sleep loop is the whole wait.