DispatchWorkItem not notifying main thread

后端 未结 1 1850
醉话见心
醉话见心 2021-01-28 02:37

Note: This is not duplicate question I have already seen Dispatch group - cannot notify to main thread

There is nothing answered about DispatchWorkItem<

相关标签:
1条回答
  • 2021-01-28 03:17

    If you are running asynchronous code in a playground then you need to enable indefinite execution, otherwise execution may end before the callbacks execute.

    Add the following lines to your code in the playground:

    import PlaygroundSupport
    PlaygroundPage.current.needsIndefiniteExecution = true
    

    Once you do this, you will see that the notify executes correctly on the main queue.

    0 讨论(0)
提交回复
热议问题