Tyler
Tyler

Reputation: 1049

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 starts and when I look under "Settings > Background Tasks" on the emulator nothing is listed.

Upvotes: 7

Views: 2890

Answers (1)

Claus Jørgensen
Claus Jørgensen

Reputation: 26345

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.

Upvotes: 9

Related Questions