Indicates that the task should stop running.
- iOS 13.0+
- macOS 10.15+
- tvOS 13.0+
- watchOS 6.0+
Task cancellation is cooperative: a task that supports cancellation checks whether it has been canceled at various points during its work.
Calling this method on a task that doesn’t support cancellation has no effect. Likewise, if the task has already run past the last point where it would stop early, calling this method has no effect.