I needed to read the registry every system login in order to determine whether to launch a notification or not. So I had to create an out-of-process background task with SystemTriggerType.SessionConnected to do this. The background task implementation would look something like this:
public async void Run(IBackgroundTaskInstance taskInstance)
{
Task launchFullTrust = LaunchFullTrustProcessForCurrentAppAsync(); //Windows.ApplicationModel.FullTrustProcessLauncher as an async task
launchFullTrust.Wait();
BackgroundTaskDeferral appServiceDeferral = taskInstance.GetDeferral();
AppServiceTriggerDetails details = taskInstance.TriggerDetails as AppServiceTriggerDetails;
Connection = details.AppServiceConnection; // AppServiceConnection object
...
// perform data acquisition
}
But because this background process is triggered by the session connectivity, it is guaranteed that taskInstance will not contain AppServiceTriggerDetails, or anything related to the AppServiceTrigger at all. Considering this, is there a way to receive a handle to the AppServiceConnection connection from the background task, and not from the UWP app itself?
To answer the main question if it is possible to launch a FullTrust Win32 app from an out-of-process background task: Yes
But the Win32 app will trigger the
OnBackgroundTaskActivatedfunction of the Main UWP application. This means it would be better to continue from said function and obtain a handle to theAppServiceConnectionfrom there. I was hoping to have a way to receive the connection on the background-task itself, but this situation seems workable for me. I am able to continue with this approach.