1 year ago

#357489

test-img

Yonghui

How to create a new Window in a new Thread with WinUI3 C++ unpackaged app?

I didn't found any documentation about this in C++. I used to use

winrt::Windows::ApplicationModel::Core::CoreApplication::CreateNewView(); to create a new view in UWP.

But now, I don't know how to do:

co_await wil::resume_foreground(*viewResource->Dispatcher.get());

// Here is still previous thread
DebugHelper::OutputCurrentThreadInfo();

winrt::Microsoft::UI::Xaml::Window testWindow = 
winrt::Microsoft::UI::Xaml::Window();
co_await wil::resume_foreground(testWindow.DispatcherQueue());
auto rootFrame = Microsoft::UI::Xaml::Controls::Frame();
rootFrame.Navigate(winrt::xaml_typename<EditPage>());
testWindow.Content(rootFrame);
testWindow.Activate();
co_await winrt::resume_background();

co_await winrt::resume_background();

Please help me. thanks

c++

windows-runtime

winui-3

c++-coroutine

0 Answers

Your Answer

Accepted video resources