What is the proper way to make CADisplayLink
callback functions run on a background thread? I'm creating the Display Link with:
let displayLink = CADisplayLink(target: self, selector: #selector(self.renderBackground))
if let displayLink = displayLink {
displayLink.preferredFramesPerSecond = 30
DispatchQueue.main.async {
displayLink.add(to: .current, forMode: .common)
}
}
This works, but when I add a breakpoint to the renderBackground function, it shows it is on the Main thread:
It appears to be on the main thread?
A
CADisplayLink
is intended to provide callbacks synchronized with the screen refresh, which takes place on the main thread. It doesn't make sense to synchronize an event that occurs on the main thread with calls on another thread.I suspect there is no way to do this.