Created
June 8, 2017 16:42
-
-
Save mikeash/241822102467006e5a5af8ca884c5837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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