Last active
August 15, 2023 17:33
-
-
Save shoheiyokoyama/64c047fc39e59211d9a0cda4a4d803cd to your computer and use it in GitHub Desktop.
DispatchWorkItem cancel()
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let queue = DispatchQueue(label: "queue", attributes: .concurrent) | |
let workItem = DispatchWorkItem { | |
print("done") | |
} | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1)) { | |
queue.async(execute: workItem) // not work | |
} | |
workItem.cancel() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
does workItem.cancel() cancels the current item which is executing currently?