Re: Dealing with multiple tasks
Re: Dealing with multiple tasks
- Subject: Re: Dealing with multiple tasks
- From: Sherm Pendley <email@hidden>
- Date: Thu, 1 Apr 2004 22:15:31 -0500
On Apr 1, 2004, at 1:28 AM, Chad Armstrong wrote:
I have a series of tasks (via NSTask) I want to run in a sequential
order. Right now I am using a standard FOR loop to run through the
tasks, and I use a waitUntilExit call to pause everything until the
current task is complete, before moving onto the next step. This
works OK, but it seems that I can't interrupt or terminate this task
while it is running (say, via a Cancel button). Is there an option
here?
Will separating the task ([myTask launch]) into a new thread help at
all, or will this just complicate matters?
The waitUntilExit method will block the current thread, so launching
the task in a separate thread is really the only option if you want to
allow for canceling the task with a Cancel button.
To handle the cancel button, you can send it a SIGINT with the
interrupt method, or a SIGTERM with the terminate method. To send it
some other signal (such as SIGKILL if it's being stubborn...) get the
task's PID with the processIdentifier method, and use the kill(pid,
sig) function to send the signal.
sherm--
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.