I am running a certain task under UIBackgroundTaskIdentifier
since i want to run it in background. My code looks something like this.
-(void) function
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), ^{
UIBackgroundTaskIdentifier BGIdentifier = [[UIApplication sharedApplication] beginBackgroundTaskWithExpirationHandler:^{}];
// some processing
dispatch_async(dispatch_get_main_queue(), ^{
// some UI stuff
});
// some processing again
dispatch_async(dispatch_get_main_queue(), ^{
// some UI stuff again
});
[[UIApplication sharedApplication] endBackgroundTask:BGIdentifier];
});
}
So I have two questions.
- If my app goes to background while some processing is happening what will happen to the dispatch_async calls to main queue?
- Is this a good design ?