Re: NSTask dilema...
Re: NSTask dilema...
- Subject: Re: NSTask dilema...
- From: Jean-Nicolas Jolivet <email@hidden>
- Date: Wed, 31 Mar 2010 15:01:32 -0400
Ok apparently everyone agrees on the fact that I should just launch the tasks on the main thread, and avoid using waitUntilExit (using only the notifications to know when a task completes...)! :)
Well, it makes sense I guess haha! I'm pretty sure I tried it before but the problem was that my progress label was not being updated... so I assumed that my UI was locked up... it turns out using [progressLabel display]; did the trick (I guess it's forcing it to re-draw?)
Thanks to everyone for the quick replies!
Jean-Nicolas Jolivet
On 2010-03-31, at 2:21 PM, Jean-Nicolas Jolivet 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...
>
> - If I try to dispatch each task in the background using GCD (dispatch_group_async and the global queue), it works just fine (and it's really fast too!), but I can't use NSTask's waitUntilExit (I know NSTask is not thread safe but I'm not sharing any NSTasks between threads...however, using waitUntilExit makes the app crash...badly...)... so basically I can use GCD to dispatch the NSTasks but then there's no way to be notified when the task are completed....(obviously I'm not receiving the NSTaskDidTerminateNotification notification either since each tasks are launched in a different thread)
>
>
> So I guess my question is... if using threads prevents me from using waitUntilExit... and launching them on the main thread locks up my UI... is there anything I am missing?
> Any help would be appreciated
>
> Jean-Nicolas Jolivet
_______________________________________________
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