• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Terminating a task
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Terminating a task


  • Subject: Re: Terminating a task
  • From: "Sailesh Agrawal" <email@hidden>
  • Date: Tue, 21 Oct 2003 14:09:07 -0400

It requires more lines of code. Try the following:

-(void) runTask(void)
{
myTask = [[NSTask alloc] init];

[[NSNotificationCenter defaultCenter]
addObserver:self
selector:@selector(taskTerminated:)
name:NSTaskDidTerminateNotification
object:myTask];
[myTask launch];
}

- (void) taskTerminated:(NSNotification*)note {
[myTask release];
myTask = nil;
}

- (IBAction) onAbortButton:(id)sender {
if (myTask)
{
[myTask terminate];
}
}


On Tue, 21 Oct 2003 01:30:20 -0500, "Chad Armstrong" <email@hidden>
said:
> If I have some code which is using NSTask's waitUntilExit call to
> determine when the task has been completed, is it possible to intervene
> at all (such as a Stop/Cancel button being pressed) to call a terminate
> method, or is waitUntilExit built so it can't be interrupted?
>
> - (void) waitUntilExit
> Suspends your program until the receiver is finished. This method first
> checks to see if the receiver is still running using isRunning . Then
> it polls the current run loop using NSDefaultRunLoopMode until the task
> completes.
>
> This was the text from Apple's reference page for NSTask, so it doesn't
> seem overly possible. Any ideas?
>
> Chad Armstrong
> email@hidden
> _______________________________________________
> 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.
_______________________________________________
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.

References: 
 >Terminating a task (From: Chad Armstrong <email@hidden>)

  • Prev by Date: Re: Editing items
  • Next by Date: Re: Terminating a task
  • Previous by thread: Terminating a task
  • Next by thread: Re: Terminating a task
  • Index(es):
    • Date
    • Thread