0

I have a long running operation with a bunch of "_isCancelled" flags

// long running code
if (_isCancelled)
  return;

// more code
if (_isCancelled)
  return;

// more code

if (_isCancelled)
  return;

// etc.

but it would be much cleaner and easier to add more "long running code" if I could somehow abort the operation from an "outside" listening thread

for instance

-(void)longRunningAsyncOperation
{
  @try {
   // long running operation
  } @catch
  {
   // if aborted just return
  }
}

-(void)cancelOperation
{
// raise an exception on a "listening" thread
}

Any thoughts on this approach? is it possible?

Avba
  • 14,822
  • 20
  • 92
  • 192

0 Answers0