Wednesday, 5 August 2020

Working with UI controls from Non main thread in Kotlin


import org.jetbrains.anko.doAsync
import org.jetbrains.anko.uiThread


fun anyFunction(){
doAsync {
      // Normal code inside Async thread
      I=I+1
     If(I=100){

    uiThread {

        tvResult.setText =”I is now 100!!”
      }
    }
   //More code
   If(x==0){
     uiThread {

        tvResult.setText =”there’s some problem!”
      }
   }


}
}

Note: - you can include multiple uiThread inside same doAsync
          - you can include multiple doAsync inside any function

No comments:

Post a Comment

Create a Directory from existing disk in proxmox server

Scenario:   I have an NVMe disk with an ext4 partition that was previously used as a directory in a Proxmox server. After reinstalling Proxm...