2
我有一个异步任务o执行计算和动画,当动画开始时,队列挂起,当动画结束时,队列恢复。但由于某种原因,DispatchQueue.main.sync永远不会被调用。DispatchQueue main不叫
self.someQueue = DispatchQueue(label: "Animation", qos: .background, attributes: DispatchQueue.Attributes.concurrent)
for index in stride(from: volumeObjects.count, to: -1, by: -1) {
mainAsyncQueue.sync{
self.dynamicViewModel.currentPercentile = Float(index)/Float(volumeObjects.count)
self.currentObjectIndex = index
print(index)
DispatchQueue.main.sync {
UIView.animate(withDuration: 1, animations: {
self.updateViewModelDynamicViewModel()
}, completion: { (finished) in
self.someQueue.resume()
})
}
self.someQueue.suspend()
}
}
这仅仅是计算量小,我就用它来解决的任务比
我看不出有任何* *异步任务。 'mainAsyncQueue'实际上是'backgroundSyncQueue';) – vadian
好的变量名纳粹:P改变它 – RodolfoAntonici