通常以下代码工作正常但是当我从远程通知(APN)执行此代码时,“queue2”没有得到执行,我很想知道我在下面的代码片段中缺少什么。
//On didReceiveRemoteNotification, I am calling refresh method using singleton object
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
{
[[NetworkDispatcher sharedInterface] refresh];
}
//Created two queues, initialise in "NetworkDispatcher" init method
dispatch_queue_t queue1 = dispatch_queue_create("com.Test.NetworkDispatcher", NULL);
dispatch_queue_t queue2 = dispatch_queue_create("com.Test.NetworkDispatcher.PostRequests", NULL);
//及以下是“NetworkDispatcher”类
中的“refresh”方法- (void)refresh
{
dispatch_async(queue1, ^{
if ([self refreshWorker])
{
dispatch_async(queue2, ^{
[self syncAllParties];
});
}
});
}
dispatch_async(queue2,被点击但是syncAllParties不会一直被调用 一段时间后,当其他后api被调用时 - 这会自动开始执行 那时排队的所有请求都将被处理,就像队列被锁定并通过这些POST操作解锁一样
任何帮助都将不胜感激。