rmyhal
03/19/2021, 9:32 AMwithTimeout(time) { operation }
but without canceling the operation?
What I want to achieve: If an operation takes longer than N
millis I want to have a callback about this and I want the operation to continue working. Something like:
withTime(
time = 500L,
block = { operation },
onTimeOver = { }
)
christophsturm
03/19/2021, 9:58 AMstreetsofboston
03/19/2021, 11:20 AMrmyhal
03/19/2021, 12:30 PMwithTimeout
is getting cancelled when timeout passes and I lose my resultsursus
03/19/2021, 12:35 PMchristophsturm
03/19/2021, 12:36 PMlaunch { delay(500); callTimer()}
rmyhal
03/19/2021, 2:02 PMlaunch {
val job = launch {
// doing some long operation
}.apply { start() }
delay(N)
if (!job.isCompleted) {
// operation took longer than N millis.
}
}
And looks like it’s what I wanted. Thanks