简体   繁体   English

UWP 登录/注销后台任务

[英]UWP background task for logging in/ logging out

I am trying to find a background task which will get triggered when the user signs out and signs back in. I looked into some of the SystemTrigger types and came across SessionsConnected trigger.我试图找到一个后台任务,当用户注销并重新登录时会触发该任务。我查看了一些 SystemTrigger 类型并遇到了 SessionsConnected 触发器。 My understanding is that this is a system trigger when a session ends and that means this would be triggered on a log out and log back in. Is there a different way to use this trigger for sign in and sign out?我的理解是,当 session 结束时,这是一个系统触发器,这意味着这将在注销并重新登录时触发。是否有其他方法可以使用此触发器进行登录和注销? Or is there a different trigger to achieve this.或者是否有不同的触发器来实现这一点。

Currently, there are no other UWP APIs that could directly detect the user logging in/logging out.目前,没有其他可以直接检测用户登录/注销的 UWP API。 I think the SessionsConnected trigger that you found does the work in some scenarios.我认为您找到的SessionsConnected trigger在某些情况下会起作用。

But if you want to have a separate event for both logging in and logging out actions, then you might need to use the SystemEvents.SessionEnded Event and SystemEvents.SessionSwitch Event .但是,如果您想为登录和注销操作设置一个单独的事件,那么您可能需要使用SystemEvents.SessionEnded 事件SystemEvents.SessionSwitch 事件 These are.Net APIs that need to be used in desktop apps.这些是需要在桌面应用程序中使用的 .Net API。 So you have to create a desktop app and package the desktop app together with the UWP app using desktop bridge.因此,您必须使用桌面桥创建桌面应用程序和 package 桌面应用程序以及 UWP 应用程序。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM