title: How to fix crash thats happens when I lock and unlock the screen after 10mins?
body: <p>I have added background process support to my app using the below code before I ping the server:</p>
  
  <pre><code>UIApplication *app = [UIApplication sharedApplication];
          bgTask = [app beginBackgroundTaskWithExpirationHandler:^{
              [app endBackgroundTask:bgTask];
              bgTask = UIBackgroundTaskInvalid;
          }];
          if (!connection) {
              connection = [[NSURLConnection alloc] init];
          }
          (void)[connection initWithRequest:originalRequest delegate:self];
  </code></pre>
  
  <p>Because of this code if I keep the application in background mode more than 10mins it is crashing. As per my understanding I should not allow tasks to run in background continuously, I should set some time interval for each task. But I don't know how to set the time interval to kill them. </p>
  
  <p>Please suggest me some steps to solve this issue.</p>