Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Periodictask not being executed

In my WP7 app I am using a periodic task.

Whe I use the code for debugging to launch the Periodic Task it runs as expected i.e.

ScheduledActionService.LaunchForTest(periodicTaskName, TimeSpan.FromSeconds(60));

However when I just add it to the action service it will not execute i.e.

ScheduledActionService.Add(periodicTask);

The code is never executed. Its the same issue as http://forums.create.msdn.com/forums/t/91617.aspx

I have downloaded several sample apps and its the same in all of them. As soon as I comment out the LaunchForTest code then the task is not run. Its the same in the emulator and on the phone. I have checked the Phone > Settings > Background tasks and my task is there and 'on'.

The only thing I do see is the following in the output window when running in debug via the emulator

The thread '<No Name>' (0xf25003e) has exited with code 0 (0x0).

When I am running the ScheduledActionService.LaunchForTest code then I see a similar message, but I also see that assemblies have been loaded etc - and the code is performed.

Any ideas? Its very frustrating. - Thanks!

like image 429
Peter Avatar asked Nov 04 '22 13:11

Peter


1 Answers

Make sure to check background service details are added to WPAppManifest.xml file. Below is the sample

<Tasks>
  <DefaultTask Name="_default" NavigationPage="MainPage.xaml" />
  <ExtendedTask Name="BackgroundTask">
    <BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="Task_Name" Source="Assembly_Name" Type="Assembly_Name.ScheduledAgent" />
  </ExtendedTask>
</Tasks>

A while ago i had same problem, it looks like when you add background agent project to your foreground project, it is missing update the manifest file.

like image 99
Mahender Avatar answered Nov 09 '22 13:11

Mahender