开发者

NSTimer and long task

开发者 https://www.devze.com 2022-12-16 18:42 出处:网络
I am wondering what happen if my NSTimer fires every 1 second and my function takes 2 seconds to per开发者_StackOverflowform the task.

I am wondering what happen if my NSTimer fires every 1 second and my function takes 2 seconds to per开发者_StackOverflowform the task.

Thanks for your answer.

Thierry


Is your function blocking? According to the documentation,

A timer is not a real-time mechanism; it fires only when one of the run loop modes to which the timer has been added is running and able to check if the timer’s firing time has passed. If a timer’s firing time occurs while the run loop is in a mode that is not monitoring the timer or during a long callout, the timer does not fire until the next time the run loop checks the timer. Therefore, the actual time at which the timer fires potentially can be a significant period of time after the scheduled firing time.

Therefore, your timer will not fire during the task if it is blocking.

0

精彩评论

暂无评论...
验证码 换一张
取 消