windows-phonebackground-agents

Does WP7 background agent have to be in a separate DLL?


Reading up on background agents in Windows Phone. All guides say I should start with creating a new project specifically for the agent. Is that a requirement? Cite place.

The bigger question is - how does the framework find the class that implements the scheduled task? AFAIK, starting a background task involves calling ScheduledActionService.Add() passing a ScheduledAction-derived object as a parameter. Nowhere in here can I see any pointer to the identity of task's implementation. Neither are tasks registered in the manifest.


Solution

  • Neither are tasks registered in the manifest.

    They are. See the "BackgroundServiceAgent" element in your manifest file: http://msdn.microsoft.com/en-us/library/windowsphone/develop/ff769509(v=vs.105).aspx

    In the end, I don't know if creating a separate project is a requirement. By manually adding the line in the manifest and pointing to a class in the main project, I don't see what could technically prevent the background agent from working. I haven't tried though. Still, putting the background agent in a separate assembly can be convenient: the memory limit for agents is ridiculously low, so not having to load the main project and its dependencies can probably save a few hundreds KB of memory