Skip to content

Instantly share code, notes, and snippets.

@mikeash
Created June 8, 2017 16:42
Show Gist options
  • Save mikeash/241822102467006e5a5af8ca884c5837 to your computer and use it in GitHub Desktop.
Save mikeash/241822102467006e5a5af8ca884c5837 to your computer and use it in GitHub Desktop.
import Foundation
let timer = DispatchSource.makeTimerSource(queue: .main)
timer.scheduleRepeating(wallDeadline: .now(), interval: .milliseconds(100), leeway: .milliseconds(100))
var count = 0
timer.setEventHandler(handler: {
count += 1
print("hello \(count)")
if count >= 10 {
exit(0)
}
})
timer.resume()
dispatchMain()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment