title: why beginBackgroundTaskWithExpirationHandler ending early?
body: <p>I am trying to get this to work correctly but it always seems to end early at 174 seconds (2.9 mins). I been following every tutorial possible online on how to use beginBackgroundTaskWithExpirationHandler and I don't see anything wrong with my code. I need this to end at 8.5 mins. The endBackgroundTask method doesn't even gets call before the expiration handler gets called. Is anything wrong with this?</p>
  
  <pre><code>- (void)applicationDidEnterBackground:(UIApplication *)application {
  
          if([[UIDevice currentDevice] respondsToSelector:@selector(isMultitaskingSupported)])
      {
          NSLog(@"Multitasking Supported");
  
          backgroundTask = [application beginBackgroundTaskWithExpirationHandler:^ {
              NSLog(@"Terminated");
  
              //Clean up code. Tell the system that we are done.
              [application endBackgroundTask: backgroundTask];
              backgroundTask = UIBackgroundTaskInvalid;
          }];
  
          timer = [NSTimer scheduledTimerWithTimeInterval:1
                                                   target:self
                                                 selector:@selector(count:)
                                                 userInfo:nil
                                                  repeats:YES];
      }
      else
      {
          NSLog(@"Multitasking Not Supported");
      }
  
  }
  
  
  
  -(void)turnOffDesktops:(NSTimer *)time {
  //do smth
  if(count &lt; (60*8.5)){
      NSLog(@"%d",count);
      count++;
  }else{
  
      [application endBackgroundTask: backgroundTask];
      backgroundTask = UIBackgroundTaskInvalid;
  
      [timer invalidate];
      timer = nil;
      count = 0;
  }
  </code></pre>
  
  <p>}</p>