You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I create a consle application based on C++\Winrt , here is the source code.
int main(int argc, char* argv[])
{
init_apartment();
// Construct the toast template
WCHAR szToast[1024] = { 0 };
LoadString(GetModuleHandle(NULL), IDS_TOAST_MESSAGE, szToast, sizeof(szToast) / sizeof(WCHAR));
winrt::param::hstring hStr(szToast);
XmlDocument doc;
doc.LoadXml(hStr);
// Construct the notification
ToastNotification notif{ doc };
// And send it!
auto notifier = ToastNotificationManager::CreateToastNotifier(_win32Aumid);
auto notifierSetting = notifier.Setting();
switch (notifierSetting)
{
case winrt::Windows::UI::Notifications::NotificationSetting::Enabled:
notifier.Show(notif);
break;
case winrt::Windows::UI::Notifications::NotificationSetting::DisabledForApplication:
break;
case winrt::Windows::UI::Notifications::NotificationSetting::DisabledForUser:
break;
case winrt::Windows::UI::Notifications::NotificationSetting::DisabledByGroupPolicy:
break;
case winrt::Windows::UI::Notifications::NotificationSetting::DisabledByManifest:
break;
default:
break;
}
return 0;
}
This code works well on windows11, but does not work on windows 10. If I add some operation code before return 0, such as cout << "what ever"<<endl; or sleep(100);, it can work on windows 10 too. It seems the application should wait for a moment after calling ToastNotifier.Show on windows 10.
Why does this happen? Is there any way to get the result of calling ToastNotifier.Show?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
ID: fba4f440-628a-7bc1-db2f-bde22e45e28d
Version Independent ID: b534bcdf-85a7-614c-1777-9a01b960cc2b
[Enter feedback here]
I create a consle application based on C++\Winrt , here is the source code.
This code works well on windows11, but does not work on windows 10. If I add some operation code before
return 0,
such ascout << "what ever"<<endl;
orsleep(100);
, it can work on windows 10 too. It seems the application should wait for a moment after calling ToastNotifier.Show on windows 10.Why does this happen? Is there any way to get the result of calling ToastNotifier.Show?
Document Details
⚠ Do not edit this section. It is required for learn.microsoft.com ➟ GitHub issue linking.
The text was updated successfully, but these errors were encountered: