hallvard
11/16/2018, 7:34 AMdelay()
in any coroutine, but not when using Anko's doAsync { }
. What am I missing? How should I handle it?louiscad
11/17/2018, 6:59 AM<http://Dispatchers.IO|Dispatchers.IO>
or Dispatchers.Default
with withContext
& launch
(or async
for parallelisation in same coroutine) instead.hallvard
11/17/2018, 12:47 PMCoroutineScope
with a single threaded scope (override val coroutineContext = Executors.newSingleThreadExecutor().asCoroutineDispatcher()
), and voilà. (I believe a single thread is OK, since this is a fairly small routine that will only query the android downloadmanager for updates every 500 millis until a certain download is finished.) Thanks for pointing me in the right direction.louiscad
11/17/2018, 4:18 PM<http://Dispatchers.IO|Dispatchers.IO>
or Dispatchers.Default
instead of a new executor?hallvard
11/17/2018, 8:35 PMGlobalScope
, I guess, and once I added inheritance of CoroutineScope
, I was asked by Android Studio to implement val coroutineContext
, and before you knew it...hallvard
11/17/2018, 8:37 PMCoroutineScope(<http://Dispatchers.IO|Dispatchers.IO>).launch { ... }
, and the effect will be the same as with Anko's doAsync { ... }
, but I'm closer to the action myself, and can do delay()
if I so wish. Nice.