loloof64
11/18/2021, 12:28 PMcoroutineScope.launch {
in order to start a coroutine in my code. But is there a variant of launch
which runs the coroutine for a given amount of time, instead of infinitely ? Because otherwise, I'm afraid my code, which is a bit a kind of spaghetti as now, will be worse.bezrukov
11/18/2021, 12:33 PMscope.launch {
withTimeout(60_000) {
// code here will be cancelled after 1 minute
}
}
loloof64
11/18/2021, 12:45 PMJoffrey
11/18/2021, 2:00 PMwithTimeout(1.minutes)
๐ (but withTimeout(Duration)
is still experimental AFAIK even though Duration
is stable now)Javier
11/18/2021, 3:35 PM