kotlin -- Coroutine

121 阅读1分钟

执行阻塞任务后并刷新UI

CoroutineScope(Dispatchers.IO).launch {
            // long runtime work,like database, network, io
            
            // switch to main thread, and refresh UI
            launch(Dispatchers.Main) {
                // TODO
            }
        }