• 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
Question on thread communication
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Question on thread communication


  • Subject: Question on thread communication
  • From: Karim Morsy <email@hidden>
  • Date: Mon, 20 Mar 2006 20:39:42 +0100

Hi,

I'm having an app in which several threads need to communicate with each other.
I've done this as follows:
on the main thread I detach a new thread that performs a task. upon completion of the thread the main thread should perform subsequent steps. it shouldn't do so unless the detached thread has really finished execution. for the detached thread to signal to the main thread that it's done, I do this:
NSNotificationCenter *nc= [NSNotificationCenter defaultCenter];
NSNotification *n= [NSNotification notificationWithName: KMFileInitCompletedNotification object:self];
[nc performSelectorOnMainThread:@selector(postNotification:) withObject:n waitUntilDone:YES];
[pool release];


the completion steps are then performed by the main thread in the appropriate handler method.

so the questions I have are:
- is there anything problematic about this approach ?
- is there an easier/better way to do this ?

many thanks in advance,
Karim
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden
  • Follow-Ups:
    • Re: Question on thread communication
      • From: Kaelin Colclasure <email@hidden>
  • Prev by Date: Re: Getting crash reports
  • Next by Date: Re: Question on thread communication
  • Previous by thread: Re: trackingRect can't be removed?
  • Next by thread: Re: Question on thread communication
  • Index(es):
    • Date
    • Thread