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.
Asked
Active
Viewed 2,884 times
7

Tyler
- 1,019
- 12
- 27
1 Answers
9
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.

Jackson Pope
- 14,520
- 6
- 56
- 80

Claus Jørgensen
- 25,882
- 9
- 87
- 150
-
So I split it out into a seperate assembly and I see it listed in "Settings > Background Tasks" but nothing is still happening. Do I need to do anything special to debug the ScheuledTaskAgent ? – Tyler Aug 11 '11 at 00:51
-
1 minute is a insanely long period. Try set it to 0. And nope, nothing special, should just work. Try use a Toast to see if it's actually running the ShellTask at all! – Claus Jørgensen Aug 11 '11 at 00:56
-
Thanks Claus, I had the wrong class name in the Manifest, its working now. – Tyler Aug 11 '11 at 01:15
-
Visual Studio didn't add the reference for me automatically. This was the final detail that made it work... Right click on your App's project and hit Add Reference, and then select your background agent project to add it as a reference. This will also add the correct xml statement for you. – swinefeaster May 07 '12 at 06:00