I have a button in my app that calculates something. When the user taps the button, the button should be disabled. When I'm using following example my button is disabled after the loop has finished. I want the button to be disabled before the loop starts. How can I do this with the example below?
fun calc() {
myButton.isEnabled = false
for (x in 0 until 1000000000) {
println(x)
}
}