ota-ota parent bo'lsa Task {
ota-ota child bo'lsa Task {
print("child started, isCancelled = ", Task.isCancelled) // YO'Q 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 soniya
parent.cancel()
///////
ota-ota parent bo'lsa 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 soniya
parent.cancel()
Katta