PSOperations icon indicating copy to clipboard operation
PSOperations copied to clipboard

call cancel() method didn't finish the operation!

Open ichagall opened this issue 8 years ago • 2 comments

for the executing operations , call cancel() don't finish the operation really, the method just mark the operations' state as hasFinished and remove the operations from the queue, in fact these operations are still running.

ichagall avatar Nov 24 '16 07:11 ichagall

@ichagall That is the expected behavior. cancel() just sets the state, but does not itself call finish() -- you have to also do that.

EDIT: Looks like PSOperations works differently from the WWDC Operations project. From what I can tell cancel() does in fact call finish() -- I think this makes more sense.

override open func cancel() {
        stateLock.withCriticalScope {
            if isFinished {
                return
            }
            
            _cancelled = true
            
            if state > .ready {
                finish()
            }
        }
    }

scottymac avatar Apr 12 '17 23:04 scottymac

You should read the discussion in https://github.com/pluralsight/PSOperations/issues/74 as it is relevant

priteshshah1983 avatar Jun 17 '17 05:06 priteshshah1983