When I call scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
on the main thread and set time interval to 5 seconds code below timer gets executed, and after 5 seconds timer selector is called.
But if I try same in some background thread, the code below scheduledTimerWithTimeInterval:target:selector:userInfo:repeats:
will not be executed, it will wait for the timer to fire and then gets executed. Of course, in order to run the timer in the background thread, I first got an instance of NSRunLoop
and run it.
Is there a way to set the timer in the background thread and make it non-blocking, so code after it gets executed immediately?
question from:
https://stackoverflow.com/questions/12323531/difference-in-scheduling-nstimer-in-main-thread-and-background-thread 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…