0

I'm facing a wierd problem with my scheduled agent. I created it some weeks ago and it worked on my phone, I tested it and everything was all right. But today I modified it, recompiled, deployed and... it didn't start.

I added LaunchForTest, tried with different timespans... nothing worked. I've ensured that all the assemblies are correctly referenced, that I'm not using any forbidden API... And it won't start. Even with a clean & build, and a clean install. I tried on the emulator and it works.

If anybody has a clue of what could be happening... Thanks.

gjulianm
  • 834
  • 7
  • 22

2 Answers2

0

There are three options when Background Agent is not launched: Background Agent is disabled in settings, Battery level is low, Background Agent has crashed two times in row

Ku6opr
  • 8,126
  • 2
  • 24
  • 31
  • 1
    I know that, but the problem is that it does not launch when I call LaunchForTest in debugging: the Backgound Agent is enabled in settings, the battery is high (connected via USB) and it has not crashed because it didn't even start. – gjulianm Jun 05 '12 at 19:08
  • It seems I have the exact same issue right now. It worked the other day in both the emulator and the device, but OnInvoke is not called. It is called the first time the app is installed, but not after that. And I do remove the task if it exists as suggested by Jason. – Johan Paul Jan 19 '13 at 11:03
0

It sounds like you didn't delete the old schedule and create a new one.

Make sure you are doing something like this in your app (not the background agent). It will remove any existing one and add it back.

try
{
   PeriodicTask Action = (PeriodicTask)ScheduledActionService.Find(MainPage.AgentName);
   if ( Action != null)
   {
      ScheduledActionService.Remove(MainPage.AgentName);
   }

   ScheduledActionService.Add(periodicTask);
}
Jason Short
  • 5,205
  • 1
  • 28
  • 45