Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Yes, the background task needs to be located in separate project. <strong>In theory</strong> the background task could be in the original project, but then it will easily hit the memory cap, because the whole project needs to be loaded in order to run just the background task code.</p> <p>It also needs to be added into your main app project using "Add reference".<br> The project with background task also need to have class, that is a child of <strong>ScheduledTaskAgent</strong> class. </p> <p>Then (in case of WP8 app) when your app is built using Visual Studio and if the Visual Studio finds such referenced project with ScheduledTaskAgent, new entry is injected into the <strong>WMAppManifest.xml</strong> to tell the app launcher that this app has background task available and in case user actually register this task for running, WP OS should start the assembly located in app manifest. This is how it looks in the manifest file: </p> <pre><code>&lt;Tasks&gt; &lt;DefaultTask Name="_default" NavigationPage="MainPage.xaml" ActivationPolicy="Resume" /&gt; &lt;ExtendedTask Name="BackgroundTask"&gt; &lt;BackgroundServiceAgent Specifier="ScheduledTaskAgent" Name="EreaderBackgroundAgent" Source="EreaderBackgroundAgent" Type="EreaderBackgroundAgent.ScheduledAgent" /&gt; &lt;/ExtendedTask&gt; &lt;/Tasks&gt; </code></pre> <p>The <strong>DefaultTask</strong> entry just describes the default app entry point, the <strong>ExtendedTask</strong> is the entry for background task. </p> <p>Note also that when developing apps for Windows Phone 7.5, <strong>this entry had to be added manually</strong> into the manifest and it was a common problem that devs published app without this entry in manifest. </p> <p>Also another interesting discovery, if you reference in your main project -> libraryA, that is referencing another libraryB, and only the libraryB implements the ScheduledTaskAgent, then Visual Studio won't add the entry into manifest, because it cannot check indirectly referenced projects - if the libraryA has no ScheduledTaskAgent implementation, the library is not considered as background task library. But, you can again add the entry to libraryA into manifest manually and it will work just fine.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload