Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6811671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:21:21+00:00 2026-05-26T20:21:21+00:00

I use performSelectorInBackground to do calculations on a background thread to keep the main

  • 0

I use performSelectorInBackground to do calculations on a background thread to keep the main thread responsive to UI tasks. This used to work on iOS4 but seems to cause issues on iOS5. It seems that the background thread would sometimes finish successfully and report back the result and sometimes it just dies silently without an exception or other trace.

I’m wondering if there were any changes in iOS5 which have caused performSelectorInBackground to behave in an unreliable manner ?
Or is there some better alternative to performSelectorInBackground that I am not aware of ?

NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

[self.earningsController performSelectorInBackground:@selector(calculateTotalEarnings:) withObject:[NSNumber numberWithInt:_startAmount]];

[pool drain];

-------------------------------------------------------

-(NSDecimalNumber*)calculateTotalEarnings:(NSNumber*)startAmount
{
    NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];

    NSDecimalNumber *retValue = [NSDecimalNumber zero];

    @try 
    {
            retValue = [self calculateTotalsWithNumber:startAmount];

        // Post a Notification with calculated totals
         [[NSNotificationCenter defaultCenter] postNotificationName:TOTAL_EARNINGS_CALCULATED object:retValue];

    }
    @catch (NSException * e) 
    {
            NSLog("Exception: %@", [e reason]);  // never gets here
    }

    [pool release];

    return retValue;
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:21:22+00:00Added an answer on May 26, 2026 at 8:21 pm

    I wouldn’t focus exclusively on changes in performSelectorInBackground, rather I would look into your method “calculateTotalsWithNumber:” to see if it is behaving differently under iOS5. If your thread is dying sporadically then there may be something awry in its implementation causing the death. Also I would look elsewhere in your project to see if somehow another code could be interfering with the task. While it’s possible that the API changed slightly in a way that would cause background logic to die it’s not likely as millions of apps use this I’d guess. Go for something more likely such as a race condition or an unprotected iVar that needs guarding by some sort of mutex or lock.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

use this website a lot but first time posting. My program creates a number
Does detachNewThreadSelector work any different than performSelectorInBackground ? In my project I use a
i want to block the main thread until something else is done in the
I'm developing an app where I use performSelectorInBackground to do some sync task in
How can I get an indication to main UI thread in an iPhone app
Is it ok to use of a notification to communication back to the main
I am trying to monitor a thread that i set running in the background.
I'm calling a function in another thread using performSelectorInBackground. I'd like a canceling ability
Use to work with a MySQL + + (library for C + +) The
Trying to use class variables in thread and getting EXC_BAS_ACCESS. Code snippet: @interface ViewController

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.