Search code examples
windows-phone-7windows-phone

Can I use "PeriodicTask" and "ResourceIntensiveTask" together in one app on Windows Phone?


As the subject said, can I use PeriodicTask and ResourceIntensiveTask together in one app on Windows Phone?

Example, may I have a PeriodicTask and a ResourceIntensiveTask in same time?


Solution

  • Yes. According to How to: Implement Background Agents for Windows Phone:

    Each application can have only one ScheduledTaskAgent registered at a time, but you can schedule this agent as both a resource-intensive agent and a periodic agent. If your application uses both a ResourceIntensiveTask and a PeriodicTask, you can check the type of the ScheduledTask object that is passed into the OnInvoke method to determine for which task the agent is being invoked and branch your code execution as necessary.

    You should be able to call ScheduledActionService.Add() on both kinds of tasks.