Re: Threading - How its done?
Re: Threading - How its done?
- Subject: Re: Threading - How its done?
- From: Michael Vannorsdel <email@hidden>
- Date: Mon, 5 May 2008 22:28:45 -0600
It's usually unsafe to interact with UI objects from other threads.
For instance with your image well, it may be in the middle of laying
out and drawing its image in the main thread when a secondary thread
suddenly changes the image in the middle of drawing. This can cause
all kinds of random problems (and sometimes appear to work fine)
depending at what point the image was swapped.
Try changing your UI updating in your thread to calls like:
[imageWellOutlet performSelectorOnMainThread:@selector(setImage:)
withObject:pdfImage waitUntilDone:NO];
This will make sure the update is carried out on the main drawing
thread so UI updates are consistent.
Also I'm not sure what the purpose of the lock is in the first method,
it's not really doing anything.
On May 5, 2008, at 8:17 PM, Karl von Moller wrote:
I have been working on a simple application that lists all available
PDF's in the Users Documents Folder. I want to fill a Table view
with only PDF's that exist at that location. When the User selects
one of the PDF files (by highlighting it in the Table View) it is
automatically loaded into a PDF View. To make the user interface
appear more responsive and to let the User know what's going on when
a large PDF file is loaded, I thought that using Threads would be my
best answer. I have no experience using threads and like most people
out in the wild, have no clear starting place to begin learning. The
easy answer perhaps is to commit to building for 10.5 and use
NSOperation instead, but I need to be able to build for 10.4 as well!
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden