Re: Threads Question
Re: Threads Question
- Subject: Re: Threads Question
- From: Matt Neuburg <email@hidden>
- Date: Thu, 18 Mar 2010 10:39:10 -0700
- Thread-topic: Threads Question
On Wed, 17 Mar 2010 10:36:40 -0400, Philippe Sismondi <email@hidden>
said:
>Because the length of time that this secondary task takes is highly variable, I
want to be able to cancel its processing from the main app. So, I want to launch
the secondary task in a separate thread to keep the main runloop responsive.
(This is of course a very common GUI issue.)
This is not a direct answer to your question, but my experience is that
using NSOperationQueue and some form of NSOperation is a very good way to
implement this. I use this approach any time I want a lengthy, cancellable
process that leaves the GUI responsive. It keeps the threading issues very
clear, and because the operation and the operation queue are ordinary
objects, they can be retained and you can return to them at any time, which
makes it very easy to collect the results when the operation ends, or to
cancel the operation in the middle (in response to the user cancelling, for
example).
m.
--
matt neuburg, phd = email@hidden, <http://www.tidbits.com/matt/>
A fool + a tool + an autorelease pool = cool!
AppleScript: the Definitive Guide - Second Edition!
http://www.tidbits.com/matt/default.html#applescriptthings
_______________________________________________
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