Can I use beginBackgroundTaskWithName for normal app processing
<p>I have some <code>NSOperations</code> that are started regularly in my application.  They should complete even when the the application is put to background. For this, I'm using the <code>beginBackgroundTaskWithExpirationHandler</code> method.</p>

<p>Am I supposed to use the <code>beginBackgroundTaskWithExpirationHandler</code>/ <code>endBackgroundTask:</code> every time I start my task even if the app is not going to background? Or am I supposed the call the begin/end methods only when I detected a <code>UIApplicationDidEnterBackgroundNotification</code>?</p>

<p><strong>Option 1: Use background task every time</strong></p>

<pre><code>/**
 * This method is called regularly from a NSTimer
 */
- (void)processData
{
    __block UIBackgroundTaskIdentifier operationBackgroundId = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{
        [[UIApplication sharedApplication] endBackgroundTask:operationBackgroundId];
        operationBackgroundId = UIBackgroundTaskInvalid;
    }];

    NSOperation *operation = ...
    [self.queue addOperation:operation];

    operation.completionBlock = ^{
        [[UIApplication sharedApplication] endBackgroundTask:operationBackgroundId];
        operationBackgroundId = UIBackgroundTaskInvalid;
    };
}
</code></pre>

<p><strong>Option 2: Use background task only when the application is about to go to background</strong></p>

<pre><code>/**
 * This method is called regularly from a NSTimer
 */
- (void)processData
{

    NSOperation *operation =  ...
    [self.queue addOperation:operation];

}


- (void)applicationDidEnterBackground:(NSNotification *)notification
{
    __block UIBackgroundTaskIdentifier operationBackgroundId = [[UIApplication sharedApplication] beginBackgroundTaskWithName:@"EnterBackgroundFlushTask" expirationHandler:^{
        [[UIApplication sharedApplication] endBackgroundTask:operationBackgroundId];
        operationBackgroundId = UIBackgroundTaskInvalid;
    }];

    // wait for all operations to complete and then


    // let UIApplication know that we are done
    [[UIApplication sharedApplication] endBackgroundTask:operationBackgroundId];
}
</code></pre>