Xitij
10/05/2020, 8:49 AMsuspend fun jobLifecycle () = coroutineScope {
val job = launch{
println("Working....")
delay(2000L)
println("Done !")
}
delay(1000L)
job.cancel()
// delay(1L) i have to do it to print correct value of job.isCompleted below
println("isCompleted: ${job.isCompleted}") // it is printing "false" but if i delay for some time after cancelling the job it prints "true".
}
is it my computer or it really takes some time to move job from cancelling to cancelled state where isCompleted becomes true after cancellation of job or is there something im missing out pls review..Zach Klippenstein (he/him) [MOD]
10/05/2020, 3:03 PM