Post

Replies

Boosts

Views

Activity

Reply to Sequential execution of asynchronous functions. How?
Thanks for the answer My English is not very good, but I will try to explain Forget the loop and simplify There are several functions (there may be 2 or more of them) Each function has a time parameter (This is the time in seconds after which the function should start working) I could use sleep, but this does not work for me because the application hangs. Therefore I am using afteAsync (deadline). Here's a good example of how I'm doing it let operation = OperationQueue() operation.maxConcurrentOperationCount = 1 operation.addOperation {   DispatchQueue.main.asyncAfter(deadline: .now() + 10) {     print("1")   }       DispatchQueue.main.asyncAfter(deadline: .now() + 10) {     print("2")   }       DispatchQueue.main.asyncAfter(deadline: .now() + 10) {     print("3")   }     } in this case, all functions will be executed simultaneously after 10 seconds. And I need them to be executed sequentially with a pause specified in the function parameter
Aug ’21
Reply to Sequential execution of asynchronous functions. How?
robnotyou Thanks Yes, it works, but with such an implementation I don't yet understand how to do it all dynamically. I can have 10 functions, and here's how to specify the dependence on the previous one, I don't know yet operation4.addDependency(operation3) operation3.addDependency(operation2) operation2.addDependency(operation1) Thanks anyway I will think in this direction
Aug ’21