1

I have an application that needs to execute a code in background. I just created an empty background task and a thread. In theory this thread should be suspended after 10 minutes, but I saw that it was still alive. What problems can be generated rather than performance?

- (void)applicationDidEnterBackground:(UIApplication *)application
{
    [application beginBackgroundTaskWithExpirationHandler:^{
    }];

     NSThread * thread = [[NSThread alloc] initWithTarget:self selector:@selector(execute:) object:nil];
     [thread start];
}


-(id) execute: (id) obj{
    while (true) {
        NSLog(@"My thread %f", [myApplication backgroundTimeRemaining]);
        sleep(1);
    }
    return nil;
}

PS there is no UIBackgroundModes set on the plist

madLokesh
  • 1,860
  • 23
  • 49

0 Answers0