菜鸟教程小白 发表于 2022-12-11 17:13:15

iOS 如何获取后台调度队列完成状态


                                            <p><p>我已经创建了一个这样的队列</p>

<pre><code>dispatch_queue_t myBackgroundQueue;
myBackgroundQueue = dispatch_queue_create(&#34;com.google.task&#34;, NULL);


dispatch_async(myBackgroundQueue, ^(void) {
});
</code></pre>

<p>这将在按钮单击时调用,我想知道当前的后台运行队列。谢谢</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><pre><code>    dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
    BOOL ok = // some result

    // do some long running processing here

    // Check that there was not a nil handler passed.
    if( completionHandler )
    {
      // This assumes ARC. If no ARC, copy and autorelease the Block.
      [completionHandler performSelector:@selector(rmaddy_callBlockWithBOOL:)
                                  onThread:origThread
                              withObject:@(ok)    // or
                           waitUntilDone:NO];
    }
    });
});
</code></pre></p>
                                   
                                                <p style="font-size: 20px;">关于iOS 如何获取后台调度队列完成状态,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38848550/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38848550/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iOS 如何获取后台调度队列完成状态