Vivek Sharma
12/22/2021, 12:45 PMscope.launch{ // doing some work here which is having loops }
I want to stop doing that work on button click
so I tried doing like this: job = scope.launch{ // doing some work here which is having loops }
and then canceling the job : job?.cancel
but it seems like loops are executing till termination and the job is not getting canceled
Any other workaround?Tgo1014
12/22/2021, 12:52 PMyield()
in the point of the loop you want to cancel the coroutine if the parent job is cancelled. I’m trying to find some link to support this, I’ll post here if I find it.Tgo1014
12/22/2021, 12:54 PMVivek Sharma
12/22/2021, 2:29 PMNick Allen
12/22/2021, 4:30 PM