1

I've a task that renders e.g. 50 objects and saves each one as a file. It's set up to continue running in the background and notify the user when the task is completed. While in the foreground, there's a progress bar, that shows the user how far along everything is.

The rendering & writing of files are all done on custom background threads, using GCD. In order to update the progress bar, dispatch_async on the main_queue is called.


Here's my problem...

When the user enters the background, the task continues as planned and, if let alone and still in the background, notifies the user when it's complete. But if the user returns sooner, and the app is still rendering/writing, I/the user would expect to see the progress and all >>> That does not happen. Even though my method to update the progress bar is sent off via dispatch_async on main_queue, the task isn't executed (or the main_queue received if you will), until the 'renter/writing' task I sent in the background is completed and the ExpirationHandler performed.

In the 'applicationWillEnterForeground:' method I tell the app, that it should 'endBackgroundTask:' and set the instance (=self.backgroundTask) to 'UIBackgroundTaskInvalid', but that doesn't make a difference

My question...

Is there a way for me to get back control of a task (running on a GCD-custom background thread) that I sent into the background (beginBackgroundTaskWithExpirationHandler:) when the app closed?

AND/OR

Do I not specifically have to get back control, but do/set something differently?

4

0 回答 0