I want to create a function that runs every 50ms (the equivalent of `setInterval` in JS). So far, this is what I have:

```
val mainHandler = Handler(Looper.getMainLooper())
mainHandler.post(object: Runnable {
    override fun run() {
        progressBar.progress += 1
        mainHandler.postDelayed(this, 50)
    }
})

```

It works, but how do I stop the `run()` function from running any further when the progress has reached `100`? Also, is there a way to cancel the `run` and reset `progress` to `0` when I click a button (like `clearInterval` in JS)? For reference, I want this:

```
buttonView.setOnClickListener {
    stopRunFromRunning()
    resetProgressTo0()
}

progress.onReach100 {
    stopRunFromRunning()
}

```