-
Notifications
You must be signed in to change notification settings - Fork 803
Open
Labels
feature proposalNew feature proposalNew feature proposal
Description
The idea is that non WinUI3 apps that would switch to WinUI are using MessageBox and DialogBox which are blocking calls; The caller expects a return value.
Trying to create another message loop doesn't work, it crashes on return:
void MainPage::ShowDialogBlocking(winrt::Microsoft::UI::Xaml::Window const& mainWindow)
{
auto dialog = ... // ContentDialog
auto dispatcherQueue = mainWindow.DispatcherQueue();
auto as = dialog.ShowAsync();
as.Completed([&](auto const&, auto)
{
dispatcherQueue.EnqueueEventLoopExit();
});
dispatcherQueue.RunEventLoop();
}
If this could work then non WinUI3 apps will have an easier time in transiting to WinUI3.
Note that the following seems to work but I'm not sure it is reliable.
void MainPage::ShowDialogBlocking()
{
auto dialog = ... // ContentDialog
ContentDialogResult res;
bool Completed = 0;
auto as = dialog.ShowAsync();
as.Completed([&](auto const& sender, auto)
{
res = sender.as<winrt::Windows::Foundation::IAsyncOperation<ContentDialogResult>>().GetResults();
Completed = 1;
});
while (!Completed)
{
MSG msg;
if (GetMessage(&msg, 0,0,0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
feature proposalNew feature proposalNew feature proposal