Re: NSThread, drawing and waiting
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