2013-03-06 61 views
0

在一个典型的dispatch_async执行:如何检查dispatch_async队列状态?

dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ 
    // ... 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     // ... 
    }); 
}); 

要限制仅只有一个块运行:

if (_loadingFromServer) return; 
_loadingFromServer = YES; 
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^{ 
    // ... 
    dispatch_async(dispatch_get_main_queue(), ^{ 
     // ... 
     _loadingFromServer = NO; 
    }); 
}); 

有没有办法使用以检查异步模块运行,没有_loadingFromServer国旗?

dispatch_queue_set_specific在这种情况下有帮助吗?

回答