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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With