title: Background Task doesn't start
body: <p>I trying to figure out why the backgroundtask won't start, but I have no idea, what I'm doing wrong.</p>
  
  <p>What am I trying to do: I want to have an automated background task which will download the 5 latest items through a WebApi (data is a couple kB). After downloading it will check the local file, to see if there are any new items available. If so, I want to create a Badge on the LiveTile with the number of new items.</p>
  
  <p>I have the following code:</p>
  
  <pre><code>private BackgroundTaskRegistration ScheduleBackgroundTask()
  {
      foreach (var cur in BackgroundTaskRegistration.AllTasks)
      {
          if (cur.Value.Name == "TimeTriggeredTask")
          {
              return (BackgroundTaskRegistration)(cur.Value);
          }
      }
  
      var builder = new BackgroundTaskBuilder();
  
      builder.Name = "TimeTriggeredTask";
      builder.TaskEntryPoint = "Tasks.UpdateItemTask";
      builder.SetTrigger(new MaintenanceTrigger(15, false));
      builder.AddCondition(new SystemCondition(SystemConditionType.InternetAvailable));
      builder.AddCondition(new SystemCondition(SystemConditionType.UserNotPresent));
  
      BackgroundTaskRegistration task = builder.Register();
      return task;
  }
  </code></pre>
  
  <p>And my job looks like this:</p>
  
  <pre><code>namespace Tasks
  {
      public sealed class UpdateItemTask : IBackgroundTask
      {
          public async void Run(IBackgroundTaskInstance taskInstance)
          {
              Debug.WriteLine("Starting");
  
              BackgroundTaskDeferral _deferral = taskInstance.GetDeferral();
  
              DataHandler dataHandler = new DataHandler();
              BindableCollection&lt;GeekAndPokeItemViewModel&gt; latestItemsOnline = await dataHandler.GetData("10");
              BindableCollection&lt;GeekAndPokeItemViewModel&gt; latestItemsLocal = await dataHandler.GetLocalData();
  
              int difference = latestItemsOnline.Except(latestItemsLocal).Count();
  
              if (difference &gt; 0)
              {
                  BadgeUpdateManager.CreateBadgeUpdaterForApplication().Clear();
                  BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent((uint)difference);
  
                  // send the notification to the app's application tile
                  BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update(badgeContent.CreateNotification());
              }
  
              _deferral.Complete();
          }
      }
  }
  </code></pre>
  
  <p>In my appmanifest the backgroundTask is extended with the Task "timer" and with the correct entrypoint. </p>
  
  <p>All code is in 1 project.</p>
  
  <p>Even with the debugger attached (debug the program without starting the app, and force to fire the task), it wont hit my task (or breakpoint) and in the eventviewer it gives the result of:</p>
  
  <blockquote>
    <p>The background task with entry point Tasks.UpdateItemTask and name TimeTriggeredTask failed to activate with error code 0x80010008.</p>
  </blockquote>
  
  <p>I've been checking <a href="http://msdn.microsoft.com/en-us/library/windows/apps/xaml/hh977059.aspx" rel="nofollow">The samples of MS background Tasks</a>, but even those are not helping. I would suggest this isn't that hard but I cant get it work.</p>