Skip to content

Main Queue

DispatchQueue.main is connected to the Android main (UI) thread. Work items submitted to the main queue are dispatched as Android Runnable objects on the UI thread, so UI updates and other main-thread operations behave as expected.

Schedule work on the main queue from any thread:

DispatchQueue.global().async {
let result = performExpensiveOperation()
DispatchQueue.main.async {
updateUI(with: result)
}
}

RunLoop.main supports adding timers and performing blocks on the main thread. Calling RunLoop.main.run() or RunLoop.main.run(until:) is not supported on Android.

Schedule a block on the main run loop:

RunLoop.main.perform {
updateUI()
}