Replies: 2 comments 5 replies
-
From what I remember, Microsoft.UI.Xaml.Application.Start works in a way that can be described as follows. It isn't exact, but it is good enough for describing this.
It is not asynchronous at all. The lambda is just a convenient way to provide the start callback without having to write an extra function.
The lambda is essentially equivalent to this. |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks a lot. So where does OnLaunched fit in? Is it also called synchronously, before the message loop starts? Or maybe I should just ask when the WinUI resources can first be used. |
Beta Was this translation helpful? Give feedback.
5 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I've been trying to understand the timing of
Application::OnLaunched
. I don't understand if it's called asynchronously by default. The actual code that starts the application and message loop is something like this:The lambda suggests that something asynchronous is happening, but I'm not sure.
What I'd like to know specifically is this: I've converted a WinUI project into an out-of-process COM server, with the help of ATL. ATL registers the class factories in the pre-message-loop, and then I use the above-quoted code as the message loop. Everything by default is single/apartment-threaded. I'd like to know whether, when a client first instantiates one of my server components, triggering COM to load up my server, whether there's any logical guarantee that
Application::OnLaunched
will have been called when the COM component is instantiated. Or stated in a different way: is it all conceivable that the out-of-process client has instantiated one of my server's classes, beforeApplication::OnLaunched
has been reached? I want to make sure all WinUI resources are available when the COM classes get instantiated and start doing things.It seems like the message loop will necessarily have started, because otherwise the client wouldn't be able to call into the class factory code to instantiate the class.
And anecdotally, it seems that
Application::OnLaunched
is always reached first, which is good. But I don't know if there's a race condition lurking in there somewhere.Thanks for any help or thoughts.
Beta Was this translation helpful? Give feedback.
All reactions