Specify to call someting when main thread is idle
Say I have a low priority job. Like checking queues whether there are URL to grab, or stuff.
How can I do that?
I can use timer to check every seconds but I am sure the开发者_JAVA技巧re are better ways.
You can use GCD to schedule a task with low priority in the main queue.
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), ^{
//Your code here
});
You can put this code within a loop, timer or whatever you want.
精彩评论