question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Question: Window.Closed and separate before/after close events

See original GitHub issue

Microsoft.UI.Xaml.Window has a Closed event but no Closing/BeforeClose/CloseRequested/etc events. Inspecting WindowEventArgs, it appears to have a Handled property, which indicates that this event is actually called prior to the window actually closing (or else it wouldn’t be settable).

Shouldn’t the name for this event be Close or CloseRequested and not Closed (past tense)? Is there any interest in specifying two separate events with one being tentative (a close was requested) and another being actual (the form is closing and there’s nothing you can do about it) à la SWF/WPF, to simplify the handling?

The problem is evident when there are multiple independent observers of Window.Closed and one randomly sets the “handled” flag. Depending on the call order, other observers may or may not see the handled state and be left thinking that the window has closed when it hasn’t.

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
riverarcommented, Jun 11, 2022

Can we plan to fix this properly for 2.0 and not hide behind “API change is hard”? The major increment will give you cover.

0reactions
castorixcommented, Jun 12, 2022

They added AppWindow.Closing since, to cancel or not closing

Read more comments on GitHub >

github_iconTop Results From Across the Web

Closing += (s, e) => [duplicate]
Closing event is self-explanatory and it is risen when window is closed. Subscribing to an event, in other words, means that you just...
Read more >
Window: close() method - Web APIs - MDN Web Docs - Mozilla
The Window.close() method closes the current window, or the window on which it was called.
Read more >
No way to detect that a window or tab is closing before it's ...
In the WebExtensions API, windows.onRemoved and tabs.onRemoved are only fired after the window or tab in question has already been removed ...
Read more >
How to detect browser or tab closing in JavaScript
A tab or window closing in a browser can be detected by using the beforeunload event. This can be used to alert the...
Read more >
Get event when window has been closed
I want to start a new task when the printing window has been closed (it closes automatically after saving the file). My current...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found