# NOT RUN {
counter <- 0L
do <- function() {
callback <- function() {
counter <<- counter + 1L
if (runif(1) < 1/10) t$cancel()
}
t <- async_timer$new(1/1000, callback)
}
run_event_loop(do())
counter
# }
Run the code above in your browser using DataCamp Workspace