Keep the undo property for your stream and periodically check it in your stream. You need to either use a lock or an atomic function (as provided by the operating system and its frameworks, but not implemented by yourself!) To indicate that the stream should be canceled. System atomic functions are described in the man page atomic.
NSOperation NSOperationQueue NSThread. - , , NSOperation isCancelled, , NSOperation NSOperationQueue.
, " ", . , , , , . , .