[Desktop Bridge] [UWP] Windows Service invoking a background task, user-level vs system-level?

Tyler Fonzi 26 Reputation points
2022-02-18T15:04:27.2+00:00

I am currently experimenting with a Desktop Bridge application where the main project is a Windows Packaging Project which packages a Windows Service project along with a UWP Runtime component for executing a VPN Client style background task. I want this windows service to invoke the background task via the Windows Networking VPN API. I've gotten this setup working with a .Net 6.0 Console application instead of a windows service, but whenever I adapt this to a windows service, it doesn't work. The service is created successfully when I deploy the app, but while it runs, it appears to be unable invoke the background task (I do not get an error that I can see, but radio silence log-wise). The issues with this has prompted the following questions:

  1. Is there something fundamental with how UWP works that could be blocking me here? I can see there being problems if this is something out of scope for UWP (as I think UWP applications are user-level while the Windows Service would be system-level)?
  2. If that is the case, are UWP apps able to be run on system-level?
  3. If calling a background task via windows service is possible in general, is there something special I need to do with my package manifest? I have two extensions, one for the windows service and one for the background task. I think I have the right entrypoints and capabilities.

If anyone has partial insight into any of these questions/topics, I would greatly appreciate it.

Universal Windows Platform (UWP)
Windows API - Win32
Windows API - Win32
A core set of Windows application programming interfaces (APIs) for desktop and server applications. Previously known as Win32 API.
2,411 questions
{count} votes

2 answers

Sort by: Most helpful
  1. Roy Li - MSFT 31,551 Reputation points Microsoft Vendor
    2022-02-23T06:08:58.957+00:00

    Hello,

    Welcome to Microsoft Q&A!

    I've talked with the team about this. Based on the response I got, that you want to implement- triggering the background from a windows service is not possible. Now, in the OS, Services have always run in session 0. When the first user to log on is connected to session 1, the second user to log on is connected to session 2, and so on. Session 0 does not support processes that interact with the user.
    This means that a service cannot post or send a message to an application and an application cannot send or post a message to a service.

    Thank you.


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    1 person found this answer helpful.

  2. Tyler Fonzi 26 Reputation points
    2022-02-23T18:07:30.037+00:00

    After discussion in comments, it seems like calling background tasks through a windows service is something that is unable to be done. Opting for an alternative solution without using a windows service, perhaps a long running user process instead

    0 comments No comments