https://kotlinlang.org logo
Title
m

maxmello

01/09/2019, 12:43 PM
Hey, I want to replace Android’s
Timer.schedule
(one time delayed execution) with coroutines, is there a better way than just launching a coroutine and calling delay() at the beginning? With structured concurrency, it would be able to get cancelled the same way than with cancelling the Timer, right?
a

altavir

01/09/2019, 12:53 PM
Why do you need to use it with coroutines? Timer and coroutines are two differenc concepts and it is better not to mix them
m

maxmello

01/09/2019, 12:58 PM
I don’t want to use it with coroutines, I want to replace my Timer code with coroutine code but get the same behavior
s

streetsofboston

01/09/2019, 1:10 PM
@maxmello in short, the answer to your question is "yes" :)
v

vishna

01/09/2019, 1:11 PM
it should be fine. also never used
Timer.schedule
on Android but rather
Handler.postDelayed
m

maxmello

01/09/2019, 1:48 PM
Ok, thank you 🙂