• 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: Dirk Stegemann <email@hidden>
  • Date: Thu, 28 Jul 2005 00:19:15 +0300

Hello Damien,

Am 27.07.2005 um 16:07 schrieb Damien Sorresso:

Did you call ``performSelectorOnMainThread:withObject:" from the worker thread itself?

Yes, everytime I wanted to call functions/methods from the secondary thread which *have* to be called from the main thread, I put that code into a separate method and performed that selector on the main thread.



If so, what calls were in the "tiny method" which updated the GUI?

E.g. NSProgressIndicator's 'incrementBy:' or 'setDoubleValue:' method.

Eventually, the control is like the following:

- Main thread is waiting for user input
- Main thread spawns secondary thread (using [NSThread +detachNewThreadSelector:toTarget:withObject')
- Main thread continues to wait for user input -> GUI stays responsive
- Secondary thread does the heavy work and calls once in a while the appropriate UI-updating method
within my NSWindowController object which controls the NSProgressIndicator, using the
'performSelectorOnMainThread:' method with an argument of 'waitUntilDone:YES' [*]
- Secondary thread eventually finishes und gets disposed



[*] I'm not sure about the "reentrant-ability" of NSProgressIndicator objects. Anyway, updating really does
not take much time, though... feel free to experiment. OTOH, all calls to 'performSelectorOnMainThread:'
have to be queued somehow, I guess.



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

  • Prev by Date: Re: Newbie Help understanding Core Data
  • Next by Date: Fwd: Developing for Tiger and Panther;
  • Previous by thread: Re: NSThread, drawing and waiting
  • Next by thread: Setting vertical alignment for a NSTextFieldCell ?
  • Index(es):
    • Date
    • Thread