János
János

Reputation: 35050

How to cancel GCD queue?

I need to know the number of task not yet started on a serial GCD queue. The reason is that I want them to 'cancel', like this:

if(!canceled) {
    ... do work
  }

Upvotes: 0

Views: 755

Answers (1)

János
János

Reputation: 35050

Thanks to Midhun MP change was really easy:

    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), {
// .. some code
    //HERE I need cancel queue, but with GCD it is not possible
    })

so the solution with NSOperationQueue:

    var oq = NSOperationQueue()
    oq.addOperationWithBlock({
// .. some code
    oq.cancelAllOperations()
    })

Upvotes: 1

Related Questions