title: Windows Phone background task stops prematurely
body: <p>I'm developing a WP8.1 SL app which uses <strong>background tasks</strong> (not agents!).</p>
  
  <p>My task is triggered by a TimerTrigger - once every 30 minutes (which I believe is the minimum interval for Windows Phone, right?). <strong>It is doing a lot of work, and for some reason, sometimes it gets interrupted - that is, it stops in the middle of it.</strong> The way I know it's in the middle of it is because I log what's happening and the task's work is basically the same every time.</p>
  
  <p>I deployed the app to my device yesterday to test a new approach, and everything was working fine - the background task was doing everything every time it was started - worked like a charm. Today my device needed a soft reset, so I did it (nothing was working, it happens from time to time since I updated to WP8.1). Since that moment, the background task gets interrupted every time, right in the middle of it, just as with the previous approach.</p>
  
  <p>Any ideas what can cause this? <strong>I'm thinking it may be connected to the soft reset, because - 100% success rate before it, 0% after that.</strong></p>
  
  <p><strong>What I've tried so far:</strong></p>
  
  <ul>
  <li><p>I'm logging errors, I have a try-catch around everything, I've subscribed to the UnobservedException event and to the task's Canceled event, and I'm logging the suspension count - none of these things help. There seem to be no errors, it's not suspended, and it's not canceled.</p></li>
  <li><p>I'm logging the current memory usage from time to time, and it's about 16-17MB. On my device, the limit should be 30MB, so I don't think that's a problem.</p></li>
  <li><p>I'm calling RequestAccessAsync wherever I can. I thought once should be enough, but since that soft-reset issue, i decided to put it in 1-2 other places to check if it's causing the issue. Well, it's not, or at least this didn't fix it.</p></li>
  </ul>
  
  <p><strong>What I'm not sure about:</strong></p>
  
  <ul>
  <li>I have no idea how to check the CPU time my task has consumed. I can't find a good/reliable way to do so. Also, I can't find any info that would explain why the task would be stopped in the middle sometimes, and other times - it would work fine.</li>
  </ul>
  
  <p><strong>Any ideas why my background task is sometimes stopped at the middle?</strong> I'm really having a hard time determining how to fix/improve the app and will it work at all.</p>
  
  <p>Thanks.</p>