RunnableScheduler

interface RunnableScheduler


Can be used to schedule Runnables after a delay in milliseconds. This is used by the in-process scheduler to schedule timed work.

Summary

Public functions

Unit
cancel(runnable: Runnable)

Cancels the Runnable which was previously scheduled using scheduleWithDelay.

Unit
scheduleWithDelay(
    delayInMillis: @IntRange(from = 0) Long,
    runnable: Runnable
)

Schedules a Runnable to run after a delay (in milliseconds).

Public functions

cancel

Added in 2.4.0
fun cancel(runnable: Runnable): Unit

Cancels the Runnable which was previously scheduled using scheduleWithDelay.

Parameters
runnable: Runnable

The Runnable to be cancelled

scheduleWithDelay

Added in 2.4.0
fun scheduleWithDelay(
    delayInMillis: @IntRange(from = 0) Long,
    runnable: Runnable
): Unit

Schedules a Runnable to run after a delay (in milliseconds).

Parameters
delayInMillis: @IntRange(from = 0) Long

The delay in milliseconds relative to the current time.

runnable: Runnable

The Runnable to be scheduled