Re: Sending image from separate thread back to AppController
Re: Sending image from separate thread back to AppController
- Subject: Re: Sending image from separate thread back to AppController
- From: Shaun Wexler <email@hidden>
- Date: Wed, 21 Jul 2004 10:53:24 -0700
On Jul 21, 2004, at 8:31 AM, Andrew Duncan wrote:
>
E.g. Shaun suggested this method in the AppController:
>
>
- (void)setNewImage:(NSImage *)image
>
{
>
if (pthread_main_np()) {
>
[myImageView setImage:image];
>
} else {
>
[self performSelectorOnMainThread:_cmd withObject:image
>
waitUntilDone:NO];
>
}
>
}
>
>
which is like my top-of-the-head idea, except I omit the check for
>
main thread. (Very clever little pattern there, a bit like forking.
>
Gotta remember that one.)
Yes the main thread enqueues the perform and will process it at the end
of the runloop (or the beginning of the next runloop cycle). Actually
there is no need to call -setNeedsDisplay: on the NSImageView, if you
set a new image. The view is simply marked dirty, and will be
displayed on the next runloop cycle anyway. Try setting the image
directly from your 2nd thread and see what happens; it's probably going
to work just fine as long as you don't have a race between threads all
trying to set new images...
--
Shaun Wexler
MacFOH
http://www.macfoh.com
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.