Skip to content

WindowsAppSDK (WinUI3) shutdown application before mainwindow is shown? #3278

Answered by DarranRowe
nathanAjacobs asked this question in Q&A
Discussion options

You must be logged in to vote

The documentation for Microsoft.UI.Xaml.Application.Start gives a bit of a hint. It states:

"This runs a message pump internally, and does not return until the application shuts down."

What it means by this "message pump" is the GetMessage/DispatchMessage loop. There is more evidence of this in the dispatcher queue documentation where DispatcherQueueController.CreateOnCurrentThread explicitly states that it uses a USER32 message loop. The dispatcher queue is what does the WinUI 3 event processing. This means that all you have to do is exit this loop, and there is a very simple but stupid way of doing that. PostQuitMessage. This will cause GetMessage to exit the loop.

Of course, if you are…

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@nathanAjacobs
Comment options

@nathanAjacobs
Comment options

Answer selected by nathanAjacobs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants