performSelectorOnMainThread: vs dispatch_async on main queue
2012-12-09 14:43
603 查看
By default,
the default mode. You can get around this with the variant
On the other hand,
转载:http://stackoverflow.com/questions/9335434/whats-the-difference-between-performselectoronmainthread-and-dispatch-async-on-m
-performSelectorOnMainThread:withObject:waitUntilDone:only schedules the selector to run in the default run loop mode. If the run loop is in another mode (e.g. the tracking mode), it won't run until the run loop switches back to
the default mode. You can get around this with the variant
-performSelectorOnMainThread:withObject:waitUntilDone:modes:(by passing all the modes you want it to run in).
On the other hand,
dispatch_async(dispatch_get_main_queue(), ^{ ... })will run the block as soon as the main run loop returns control flow back to the event loop. It doesn't care about modes. So if you don't want to care about modes either,
dispatch_async()may be the better way to go.
转载:http://stackoverflow.com/questions/9335434/whats-the-difference-between-performselectoronmainthread-and-dispatch-async-on-m
相关文章推荐
- -performSelectorOnMainThread:withObject:waitUntilDone: VS dispatch_async(dispatch_get_main_queue(),
- performSelectorOnMainThread的用处
- 多线程的使用(1) - performSelectorOnMainThread
- IOS线程的使用 performSelectorOnMainThread
- performSelectorOnMainThread
- performSelectorOnMainThread
- performSelectorOnMainThread (线程)
- performSelectorOnMainThread 和detachNewThreadSelector区别
- 【代码笔记】iOS-performSelectorOnMainThread
- performSelectorOnMainThread
- performSelectorOnMainThread
- 【代码笔记】iOS-performSelectorOnMainThread
- 多线程的使用(1)-performSelectorOnMainThread
- performSelectorOnMainThread
- NSOperation与performSelectorOnMainThread在不同线程中更新界面
- performSelectorOnMainThread
- iOS : performSelectorOnMainThread
- performSelectorOnMainThread
- NSOperation与performSelectorOnMainThread
- iOS中performSelectorOnMainThread刷新图片