On Wed, Mar 31, 2010 at 2:21 PM, Jean-Nicolas Jolivet <jeannicolasco...@gmail.com> wrote: > I have to run a bunch of NSTasks and I'm not sure to proceed considering I > want to be able to update the UI when a task is completed, and I want the > process to be as fast as possible (obviously)... > > So far I tried a couple of ideas but they all had their problems: > > - I tried launching the tasks on the main thread but it locks up my UI and I > can't update my progress bar...
NSTask doesn't block unless you specifically ask it to, by calling -waitUntilExit. > So I guess my question is... if using threads prevents me from using > waitUntilExit It doesn't normally prevent that. In fact, in most cases you'd only want to use it from a background thread, because using it from the main thread would block the main event loop and trigger a beach ball. > ... and launching them on the main thread locks up my UI... is there anything > I am missing? What you're missing is that NSTask doesn't (normally) block the UI thread, and that calling -waitUntilExit doesn't (normally) cause a crash when called from a secondary thread. > Any help would be appreciated Just launch your NSTask on the main thread, and *don't* call -waitUntilExit. Listen for NSTaskDidTerminateNotification, and respond to it by updating your UI. sherm-- -- Cocoa programming in Perl: http://www.camelbones.org _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com