• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
main thread communicating with background thread and vice-versa
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

main thread communicating with background thread and vice-versa


  • Subject: main thread communicating with background thread and vice-versa
  • From: John Love <email@hidden>
  • Date: Fri, 21 Nov 2008 09:24:22 -0500

From the main Thread, I call:



[NSThread detachNewThreadSelector:@selector(bgThread:) toTarget:self withObject:nil];



- (void) bgThread:(NSConnection*)connection {

    NSAutoreleasePool *pool;

    pool = [[NSAutoreleasePool alloc] init];



    [self doCalculation];



[self performSelectorOnMainThread:@selector(endBgCalculation:) withObject:nil waitUntilDone:NO];



    [pool release];

}



- (void) endBgCalculation:(id)obj {

        // stuff

}



I believe this is fairly standard way to institute a background thread …



The problem centers on letting the background Thread look at a parm set in the main Thread and break out of the background Thread when the background Thread sees a certain value.



Specifically, my –doCalculation is just one great time-consuming for- loop that looks at mainThreadParm and breaks depending on the value of mainThreadParm.



I change mainThreadParm in the main Thread and I expect the background Thread to break when the background Thread sees a certain value of mainThreadParm.



The background thread sees the initial value of mainThreadParm, but does not break when the main Thread changes it.



This sounds so basic and fundamental that I really feel lacking on this subject.



John Love

 _______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: main thread communicating with background thread and vice-versa
      • From: Joseph Kelly <email@hidden>
  • Prev by Date: Re: Cocoa "canvas" view ?
  • Next by Date: Re: Autorelease Question
  • Previous by thread: Re: BOOL value in Dictionary
  • Next by thread: Re: main thread communicating with background thread and vice-versa
  • Index(es):
    • Date
    • Thread