Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development > iPhone SDK Development - Advanced Discussion

Reply
 
LinkBack Thread Tools Display Modes
Old 07-28-2011, 04:43 AM   #1 (permalink)
Registered Member
 
Join Date: Mar 2011
Posts: 9
kwackers is on a distinguished road
Default Threading issue - is there a fix?

I'm using a 3rd party library to load data in an iPad app and because some of the large blocks of data I want to load can take an age to process I do this as a background task (otherwise the device times out, plus it maintains functionality in the UI).

This is great and works a treat, except if you press the home button to send the app into the background and then click back on the app when the app comes back the iOS has moved the thread into the foreground which basically means a few seconds later it times out and kills the app...

I'm struggling to see what possible fix there is for this.

Anyone any ideas?
kwackers is offline   Reply With Quote
Old 07-28-2011, 05:05 PM   #2 (permalink)
Senior Member
iPhone Dev SDK Supporter
 
Join Date: Jan 2010
Location: Issaquah, WA
Age: 42
Posts: 1,244
dljeffery is on a distinguished road
Default

Are you sure the background thread gets moved into the foreground? Or does the background thread crash? Or perhaps it dies when the app is left, and then the foreground thread crashes when it tries to communicate with the dead background thread?
__________________
Recall It! Tag your notes. Tag your photos. Tag your thoughts. Tag your life.

Recall It! for iPad

http://www.dljeffery.com
dljeffery is offline   Reply With Quote
Old 08-03-2011, 01:31 PM   #3 (permalink)
Registered Member
 
Join Date: Jul 2011
Posts: 241
MattW is on a distinguished road
Default

Quote:
Originally Posted by kwackers View Post
I'm using a 3rd party library to load data in an iPad app and because some of the large blocks of data I want to load can take an age to process I do this as a background task (otherwise the device times out, plus it maintains functionality in the UI).

This is great and works a treat, except if you press the home button to send the app into the background and then click back on the app when the app comes back the iOS has moved the thread into the foreground which basically means a few seconds later it times out and kills the app...

I'm struggling to see what possible fix there is for this.

Anyone any ideas?
You should pause your background thread when your app gets suspended, and then start it up again when your app comes back to the foreground.
__________________

Highlight PDF text like no other app: iHighlight (now available for iPad and iPhone!)
-----
Create iPhone lists with no typing: Insta-List
-----
Make spelling fun, and create your own tests: iWillSpell
-----
A fast, elegant flashlight app: Insta-Light
-----


FourSixteen Productions
MattW is offline   Reply With Quote
Old 10-20-2011, 10:22 PM   #4 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 113
jonusx is on a distinguished road
Default

You can probably solve this with blocks and GCD. How much data are you loading? is it from an external source?
__________________
What do you have to share? Share and view pics Oneshare

Play Magic: The Gathering? Try The Sylvan Archives!

Warhammer 40k your thing? W40k Manager is your thing.

Like karaoke? Try iSing Karaoke Locator
jonusx is offline   Reply With Quote
Old 11-23-2011, 05:52 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2009
Location: Helsinki
Posts: 304
fiftysixty is on a distinguished road
Default

Quote:
Originally Posted by kwackers View Post
I'm using a 3rd party library to load data in an iPad app and because some of the large blocks of data I want to load can take an age to process I do this as a background task (otherwise the device times out, plus it maintains functionality in the UI).

This is great and works a treat, except if you press the home button to send the app into the background and then click back on the app when the app comes back the iOS has moved the thread into the foreground which basically means a few seconds later it times out and kills the app...

I'm struggling to see what possible fix there is for this.

Anyone any ideas?
I did a bit of Googling, and it turned out this: Behaviour of threads when entering background in iOS multitasking - Stack Overflow

So it seems the background thread is suspended and resumed when the app resumes, but it should not move to the foreground. Perhaps there is some other problem why AppKit kills the app? Also, have you considered using the task completion API for the background processing?
fiftysixty is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 385
17 members and 368 guests
Absentia, AyClass, bignoggins, Diligent, dre, givensur, hussain1982, jbro, jPuzzle, LunarMoon, momolgtm, Newbie123, Paul10, revg, skog, taylor202
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,643
Threads: 94,110
Posts: 402,858
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Diligent
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 04:46 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0