![](/img/trans.png)
[英]Terminate the win32 process of UWP app from main UWP process, or send message to it
[英]Can I launch a FullTrust Win32 app from within a UWP app's out-of-process background task?
我需要在每次系统登录时读取注册表以确定是否启动通知。 因此,我必须使用SystemTriggerType.SessionConnected
创建一个进程外后台任务来执行此操作。 后台任务实现看起来像这样:
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
}
但是因为这个后台进程是由 session 连接触发的,所以可以保证taskInstance
不会包含AppServiceTriggerDetails
或任何与AppServiceTrigger
相关的内容。 考虑到这一点,有没有办法从后台任务而不是从 UWP 应用程序本身接收AppServiceConnection
连接的句柄?
要回答是否可以从进程外后台任务启动 FullTrust Win32 应用程序的主要问题:是
但是 Win32 应用程序将触发主 UWP 应用程序的OnBackgroundTaskActivated
function。 这意味着最好从所述 function 继续并从那里获取AppServiceConnection
的句柄。 我希望有一种方法可以接收后台任务本身的连接,但这种情况对我来说似乎可行。 我能够继续使用这种方法。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.