开发者

Does the ScheduledTaskAgent and PeriodicTask need to be in a seperate assembly from the main app?

I tried to follow this example from Microsoft, best I can tell I did everything except putting the ScheduledTaskAgent and PeriodicTask in a seperate assembly. When I run my app in the emulator and try to launch the Periodic task using:

ScheduledActionService.LaunchForTest(_task.Name, TimeSpan.FromSeconds(60));

Nothing happens, no exceptions and after a minute the ScheduledTaskAgent never start开发者_开发知识库s and when I look under "Settings > Background Tasks" on the emulator nothing is listed.


Yes, they need to be in a separate assembly, and you need to reference it in your WMAppManifest.xaml, like this:

<Tasks>
    <DefaultTask Name="_default" NavigationPage="Views/MainPage.xaml" />
    <ExtendedTask Name="BackgroundTask">
        <BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="DMI.ScheduledAgent" Source="DMI.TaskAgent" Type="DMI.TaskAgent.ScheduledAgent" />
    </ExtendedTask>

You can read on MSDN what the correct values for the BackgroundServiceAgent attributes are.

If you use the Visual Studio Windows Phone Scheduled task Agent template, the BackgroundServiceAgent task is automatically added in the WMAppManifest.xaml with the correct values.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜