Sobes.tech
Senior

άσε ο γονέας να είναι Task { άσε το παιδί να είναι Task { print("child started, isCancelled = ", Task.isCancelled) // ΟΧΙ false for index in (1...[phone]) { print(index) } print("child finished, isCancelled = ", Task.isCancelled) // } await child.value } try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 δευτερόλεπτο parent.cancel() /////// άσε ο γονέας να είναι Task { async let child: Void = { print("child started, isCancelled =", Task.isCancelled) for index in (1...[phone]) { print(index) } print("child finished, isCancelled =", Task.isCancelled) }() await child } try? await Task.sleep(nanoseconds: 1_000_000_000) // 1 δευτερόλεπτο parent.cancel()