I am trying to implement dispath group , to perform a sequence of operations , that should execute one after another. But the issue is all the tasks adding to the group are executing in parallel. Please share your thoughts , following is the sample I am trying.
let group = DispatchGroup()
group.enter()
print("Enter Activity One")
self.performActivityOne(param: []) {
group.leave()
print("leave 1")
}
group.enter()
print("Enter Activity two")
self. self.performActivityTwo(param: []) {
group.leave()
print("leave 2")
}
group.notify(queue: DispatchQueue.main) {
// This block will be executed once all above threads completed and call dispatch_group_leave
print("Prepare completed. I'm readyyyy")
}
The output I am getting is
Enter Activity One
Enter Activity two
leave 2
notify
closure get the keys, sort them and get the values in order. – TragicperformActivityX
calls to a serial queue, you are serializing only the starting of those asynchronous tasks, but not waiting for them to finish. – Gingham