• 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
Re: NSThread, drawing and waiting
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSThread, drawing and waiting


  • Subject: Re: NSThread, drawing and waiting
  • From: Damien Sorresso <email@hidden>
  • Date: Wed, 27 Jul 2005 08:07:10 -0500

Did you call ``performSelectorOnMainThread:withObject:" from the worker thread itself? If so, what calls were in the "tiny method" which updated the GUI?
--
Damien Sorresso
Macintosh Developer
Computer Infrastructure Support Services
Illinois State University
email@hidden
309.438.5777


On 26 Jul, 2005, at 4:59 PM, Dirk Stegemann wrote:
Hi,

Am 27.07.2005 um 00:33 schrieb Damien Sorresso:

The `RNRequirementManager' has an array of `RNRequirement' items that it goes through and calls the ``searchForItem" methods for. Here's what that code looks like.

for( i = 0; i < numResults; i++ ) {
   int condition = [[requirementsArr objectAtIndex:i] lockCondition];
   [conditionLock lock];
   [conditionLock unlockWithCondition:condition];

   [NSThread detachNewThreadSelector:@selector(searchForItem)
                        toTarget:[requirementsArr objectAtIndex:i]
                      withObject:nil];

   [conditionLock lockWhenCondition:0];
   [conditionLock unlock];

   // Tell delegate what to do
   // ...
}


I had pretty much success by spawning a "worker" thread to do the heavy work; then every time I wanted the GUI being updated using information created by this worker thread, it used NSObject's

- (void)performSelectorOnMainThread:(SEL)aSelector withObject:(id)arg waitUntilDone:(BOOL)wait;

method to run a tiny method which updates the GUI accordingly.


Regards, Dirk Stegemann

_______________________________________________ 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: NSThread, drawing and waiting
      • From: Dirk Stegemann <email@hidden>
References: 
 >NSThread, drawing and waiting (From: Damien Sorresso <email@hidden>)
 >Re: NSThread, drawing and waiting (From: Dirk Stegemann <email@hidden>)

  • Prev by Date: Text System Bugs
  • Next by Date: Re: Cocoa-dev Digest, Vol 2, Issue 1155
  • Previous by thread: Re: NSThread, drawing and waiting
  • Next by thread: Re: NSThread, drawing and waiting
  • Index(es):
    • Date
    • Thread