Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 234
Tyler Avatar asked Aug 10 '11 22:08

Tyler


1 Answers

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.

like image 200
Claus Jørgensen Avatar answered Sep 24 '22 06:09

Claus Jørgensen