如何在开机时启动后台任务 - Windows Store app
How to start background task at boot - Windows Store app
我的平板电脑运行 Windows 8.1 专业版。
它有一个后台任务,每 15 分钟由时间触发器触发一次。它有效,很公平。
问题是我需要在我的设备每次启动(启动应用程序)时自动启动我的后台任务。
我用这个代码注册了我的博客:
builder.Name = "bikePositionUpdate";
builder.TaskEntryPoint = "BackgroundTaskGps.BikeGPSPositionUpdateBackgroundTask";
builder.SetTrigger(new TimeTrigger(15, false)); //
// adding condition
SystemCondition internetCondition = new SystemCondition(SystemConditionType.InternetAvailable);
SystemCondition userPresentCondition = new SystemCondition(SystemConditionType.UserPresent);
builder.AddCondition(internetCondition);
builder.AddCondition(userPresentCondition);
BackgroundTaskRegistration taskRegistration = builder.Register();
我的应用有锁屏权限
await BackgroundExecutionManager.RequestAccessAsync();
我怎样才能做到这一点?我错过了什么吗?
您是否尝试过将应用程序添加到 Windows Task Scheduler 作为安装过程的一部分?
您是否尝试过在注册表启动时将其添加到 运行?
我没有要检查的 8.1,但如果没有从 win7 更改路径应该是 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run(或 HKEY_LOCAL_MACHINE)只需创建一个新的字符串值与您的应用程序的路径,它将是运行 当 windows 开始时
您必须添加 SystemConditionType.SessionConnected
条件,该条件会在用户每次登录 Windows 时发生。
必须先将应用置于锁定屏幕上,才能使用此触发器类型成功注册后台任务。
编辑:
在这个 url 上,您可以找到关于您需要什么以及如何使用它的官方文档:
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977056.aspx
这个 await BackgroundExecutionManager.RequestAccessAsync();
的结果应该类似于 AllowedWithAlwaysOnRealTimeConnectivity。
表示:用户在对话框中选择了"allow"。应用添加到锁屏,可以设置后台任务。
还有这个BackgroundTaskRegistration taskRegistration = builder.Register();
你应该在 await BackgroundExecutionManager.RequestAccessAsync();
之后打电话
I think you should add SystemConditionType.SessionConnected condition,where this condition will check every time theuser log on to Windows
我的平板电脑运行 Windows 8.1 专业版。
它有一个后台任务,每 15 分钟由时间触发器触发一次。它有效,很公平。
问题是我需要在我的设备每次启动(启动应用程序)时自动启动我的后台任务。
我用这个代码注册了我的博客:
builder.Name = "bikePositionUpdate";
builder.TaskEntryPoint = "BackgroundTaskGps.BikeGPSPositionUpdateBackgroundTask";
builder.SetTrigger(new TimeTrigger(15, false)); //
// adding condition
SystemCondition internetCondition = new SystemCondition(SystemConditionType.InternetAvailable);
SystemCondition userPresentCondition = new SystemCondition(SystemConditionType.UserPresent);
builder.AddCondition(internetCondition);
builder.AddCondition(userPresentCondition);
BackgroundTaskRegistration taskRegistration = builder.Register();
我的应用有锁屏权限
await BackgroundExecutionManager.RequestAccessAsync();
我怎样才能做到这一点?我错过了什么吗?
您是否尝试过将应用程序添加到 Windows Task Scheduler 作为安装过程的一部分?
您是否尝试过在注册表启动时将其添加到 运行?
我没有要检查的 8.1,但如果没有从 win7 更改路径应该是 HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Run(或 HKEY_LOCAL_MACHINE)只需创建一个新的字符串值与您的应用程序的路径,它将是运行 当 windows 开始时
您必须添加 SystemConditionType.SessionConnected
条件,该条件会在用户每次登录 Windows 时发生。
必须先将应用置于锁定屏幕上,才能使用此触发器类型成功注册后台任务。
编辑:
在这个 url 上,您可以找到关于您需要什么以及如何使用它的官方文档:
https://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977056.aspx
这个 await BackgroundExecutionManager.RequestAccessAsync();
的结果应该类似于 AllowedWithAlwaysOnRealTimeConnectivity。
表示:用户在对话框中选择了"allow"。应用添加到锁屏,可以设置后台任务。
还有这个BackgroundTaskRegistration taskRegistration = builder.Register();
你应该在 await BackgroundExecutionManager.RequestAccessAsync();
I think you should add SystemConditionType.SessionConnected condition,where this condition will check every time theuser log on to Windows