1

バックグラウンドでコードを実行する必要があるアプリケーションがあります。空のバックグラウンド タスクとスレッドを作成しました。理論的には、このスレッドは 10 分後に停止するはずですが、まだ生きていることがわかりました。パフォーマンスではなく、どのような問題が発生する可能性がありますか?

- (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 plistにUIBackgroundModesが設定されていません

4

0 に答える 0