Skip to content

Instantly share code, notes, and snippets.

@byaruhaf
Forked from yostane/dispatch7.swift
Created August 26, 2020 14:00
Show Gist options
  • Save byaruhaf/08f8142a751e71e3cbb28582c403417e to your computer and use it in GitHub Desktop.
Save byaruhaf/08f8142a751e71e3cbb28582c403417e to your computer and use it in GitHub Desktop.
DispatchWorkItem notify example
let dwi3 = DispatchWorkItem {
print("start DispatchWorkItem")
sleep(2)
print("end DispatchWorkItem")
}
//this block will be executed on a the siqpatch queue 'dq' when dwi3 completes
let myDq = DispatchQueue(label: "A custom dispatch queue")
dwi3.notify(queue: myDq) {
print("notify")
}
DispatchQueue.global().async(execute: dwi3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment