Close Portal on the first click of the X #18
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/close-on-first-click"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closing Portal with nothing running showed "Something went wrong: Cannot set Visibility to Visible or call Show, ShowDialog, Close, or WindowInteropHelper.EnsureHandle while a Window is closing". A second click on the X then closed it.
Cause
MainWindow.OnClosingcancels the close, waits for the close confirmation and the session shutdown, and then callsClose()again. With no transfers running, those waits finish immediately, so the secondClose()ran inside the firstClosingevent. WPF refuses that. The second click worked because the close was already marked as confirmed.Fix
The final
Close()is queued withDispatcher.BeginInvoke, so it runs after the first close has finished.Verification
dotnet builddotnet test Portal.slnx🤖 Generated with Claude Code