Opt out starting the application through toast notification when running as a Windows service #4899
Replies: 1 comment 1 reply
-
I was able to suppress the console window to blink quickly after the toast or a button was clicked and the app was started again by specifying the output type to
But I still need to have the workaround in the So I do not think I fixed the problem yet. |
Beta Was this translation helpful? Give feedback.
-
I am trying to integrate the NuGet package
Microsoft.Toolkit.Uwp.Notifications
in my ASP.NET Core 6 web API to deliver notifications to the user who will be supposed to have the application running in a silent way. That's why I am designing the app to run as a Windows service. The application should be capable of running a periodic job that checks some stuff on the internet by using Selenium and provide notifications to the user if something worth the notification happens.I am able to trigger the notifications from the periodic job (hosted service). When I publish the app and install it as a Windows service the activation mechanism triggered when the user clicks the toast or a button not only triggers the action handling event but also attempts to start the application again with the
-ToastActivated
cmd argument. This is quite unexpected because the app is already running and something in the notification engine probably "thinks" it isn't.I am able to prevent the web server and the web API from starting by simply checking for the input args in the Main method and bypassing the start-up. But a cmd window blinks for a moment until the auto-launched app finishes the execution of the bypassed Main method and gets closed.
I tried setting the background activation for the toast and the button on it by calling the
.SetBackgroundActivation()
but the application gets started anyways.Is there a way how to tackle this? Am I too bold to have such notifications integrated in a ASP.NET Core app that runs as a Windows Service?
I would love not to have to split the application into a service part (ASP.NET Core) and a UI part (like WPF) that would be responsible for notifications because I would then need some interprocess communication (like pipes) and this would make the whole solution more complex.
Thank you for your help in advance.
Beta Was this translation helpful? Give feedback.
All reactions