Re: Crashing when updating the User Interface from a detached NSThread
Re: Crashing when updating the User Interface from a detached NSThread
- Subject: Re: Crashing when updating the User Interface from a detached NSThread
- From: Glen Simmons <email@hidden>
- Date: Thu, 2 Feb 2006 07:09:34 -0600
On Feb 2, 2006, at 3:43 AM, Simone Manganelli wrote:
I'm having a particular problem with using NSThreads. I'm
detaching a method that runs in a separate thread, but in the
process of this method, it needs to update the user interface a
bit. (I'm multithreading the app because this method takes a
particularly long time to execute and I want the user interface to
be responsive.) Whenever this detached thread tries to update the
user interface, it seems to crash a lot.
To give a specific reason why it's necessary to update the user
interface inside this method, consider this scenario: I'm trying to
create an image from a movie by laying out each of the frames next
to each other in an image. But I want the user to know how far the
process has progressed, so I want the movie view that I'm using to
step forward and display the current frame that it's processing. I
also want to update an NSImageView to show the current assembled
image in a preview window.
Are there ways to export drawing commands back to the main
application thread so that the application doesn't crash? I tried
using an NSNotification, but that doesn't seem to work.
UI updates must be done on the main thread. There's a method that
makes this easy: performSelectorOnMainThread:withObject:waitUntilDone:.
Glen
_______________________________________________
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