let _ = Timer.scheduledTimer(withTimeInterval: 4.0, repeats: true) { (timer) in
//do something
}
I create a timer and invoke its block every 4 second. Then I make application to enter background and enter foreground after a while. But it could invoke the block quickly even less than 1 second sometimes.