Skip to content
This repository has been archived by the owner on Aug 30, 2023. It is now read-only.

How to wait for a co_routine from MFC UI thread(Button click) , which displays UWP content dialog over a WinUI hosted MFC #313

Open
VrindaJayan opened this issue Mar 22, 2021 · 3 comments
Labels
question ❔ Further information is requested

Comments

@VrindaJayan
Copy link

void CSampleDlg::OnBnClickedAdd()
{
…………...……………………...……………...…...…………..
…………...……...…...………...…………...…...…...………….
IAsyncAction async = ShowContentDialog();
async.Completed([&](IAsyncAction asynctest, AsyncStatus st)
{
asynctest.GetResults();
AfxMessageBox(L"completed ..........");
});
AfxMessageBox(L"OK before get");
async.get();
AfxMessageBox(L"After get");
CString csSNum;
GetDlgItemText(IDC_EDIT4, csSNum);
double sum = _wtof(csSNum);
m_customUctrl.SetSum(100.00);

}

Windows::Foundation::IAsyncAction CSampleDlg::ShowContentDialog()
{
ContentDialog dialog;
dialog.Content(box_value(L"Do you want to continue to update textbox?"));
dialog.Title(box_value(L"Confirmation"));
dialog.PrimaryButtonText(L"Ok");
dialog.SecondaryButtonText(L"Cancel");
dialog.CloseButtonText(L"Ok");
dialog.XamlRoot(m_customUctrl.XamlRoot());
winrt::Windows::UI::Xaml::Controls::ContentDialogResult result = co_await dialog.ShowAsync();
if (result == ContentDialogResult::Primary)
{
AfxMessageBox(L"Primary");
}
else if (result == ContentDialogResult::Secondary)
{
AfxMessageBox(L"Secondary");
}
else
{
AfxMessageBox(L"Third");
}
co_return;
}
In the above code sample, trying to display a UWP content dialog from MFC SDI application(XAML island hosted application). And to set text on a text box based on the ContentDialog button click(Primary or secondary button). Issue is the code portion after the line "async.get(); "not executed .

Issue already reported in https://docs.microsoft.com/en-us/answers/questions/322651/code-after-iasyncactionget-not-executed.html

@VrindaJayan VrindaJayan added the question ❔ Further information is requested label Mar 22, 2021
@ghost ghost added the needs triage 🔍 label Mar 22, 2021
@ghost
Copy link

ghost commented Mar 22, 2021

Hello VrindaJayan, thank you for your interest in Win32!

I have automatically added a "needs triage" label to help get things started. Our team will look into the question and answer ASAP. Other community members may also answer the question and provide feedback 🙌

@ghost ghost added the needs attention 👋 label Apr 6, 2021
@ghost
Copy link

ghost commented Apr 6, 2021

This issue has been marked as "needs attention 👋" due to no activity for 15 days. Please triage the issue so the fix can be established.

@michael-hawker
Copy link
Member

FYI @marb2000

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
question ❔ Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants