Should the ScheduledTaskAgent and PeriodicTask elements be in a separate assembly from the main application?

I tried to run this example from Microsoft, I can best say that I did everything except placing ScheduledTaskAgent and PeriodicTask in a separate assembly. When I run my application in the emulator and try to run 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 in the "Settings> Background Tasks" section on the emulator, nothing is displayed.

+7
source share
1 answer

Yes, they must be in a separate assembly, and you need to reference it in WMAppManifest.xaml , for example:

 <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 MSDN what are the correct values ​​for the BackgroundServiceAgent attributes.

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

+9
source

All Articles