后台代理不会启动预定作业 [英] Background Agent does not start a scheduled job

查看:78
本文介绍了后台代理不会启动预定作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,

我们遇到运行后台任务代理的问题。以下描述也适用于从"Windows Phone 8 JumpStart:Module 6 Background Agents Demo"下载的样本。在模拟器和真实设备上(诺基亚Lumia 920)。 

We are experiencing a problem with running Background Task Agent. The description below applies also to the sample downloaded from "Windows Phone 8 JumpStart: Module 6 Background Agents Demo" on both simulator and real device (Nokia Lumia 920). 

我们为Windows Phone 8解决方案创建了一个ScheduledAgent。使用以下代码将其添加到ScheduledActionService:

We have created a ScheduledAgent for the Windows Phone 8 solution. Added it to ScheduledActionService using the following code:

var task = ScheduledActionService.Find(TaskName) as PeriodicTask;
            if (task != null)
                ScheduledActionService.Remove(TaskName);

            task = new PeriodicTask(TaskName)
            {
                Description = "Some description"
            };

            try
            {
                ScheduledActionService.Add(task);
            }
            
            catch (SchedulerServiceException ex)
            {
                // Logging, handling logic
            }

添加了WMAppManifest条目:

added entry to WMAppManifest:

<ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="FlexNetBackgroundTasksAgent" Source="FlexNetBackgroundTasksAgent" Type="FlexNetBackgroundTasksAgent.ScheduledAgent" />
      </ExtendedTask>

然后等待超过30分钟且后台任务未启动。

and then waited for more than 30 minutes and the background task is not started.

我们验证了名称,类型等,没关系。我们还使用以下命令运行它:

We verified the names, types etc. and it is ok. We also run it for tests using:

 ScheduledActionService.LaunchForTest(TaskName, TimeSpan.FromSeconds(5));

然后它运作了。

有没有人知道为什么这不起作用?

Does anyone has the idea why this does not work?

我们还验证了该任务已启用且可见在Windows手机设置 - >应用程序 - >后台任务。

We also verified that the task is enabled and visible in windows phone Settings -> Applications -> background tasks.

推荐答案

这个
讨论可能会有所帮助,因为有很多东西都可以导致它无法启动。

This discussion may be helpful, as there are number of things that can cause it to not launch.

您还可以使用
AgentExitReason
用于诊断。

You can also use AgentExitReason for diagnostics.

其他可能的原因是电池电量不足且电池保护程序已启用,如果代理已经运行但未能在之前的两次运行中干净地退出(达到内存上限或未处理的异常)。

Other possible causes are if battery is low and battery saver is enabled, and if agent has run but failed to exit cleanly on two previous runs (hitting memory cap or unhandled exceptions).

希望这有帮助,

Mark

Hope this helps,
Mark


这篇关于后台代理不会启动预定作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆