【发布时间】:2012-04-05 18:35:22
【问题描述】:
我在我的主线程中使用 NSProgressIndicator 来更新我运行整个方法时的进度。现在,当我最终从不同的类文件中调用一个对象,并等待该对象返回到我的主线程的值时,我注意到 NSProgressIndicator 将消失。我知道这是因为在我从另一个对象获得返回值之前,主线程被阻塞了。
所以我的问题是在主线程中更新 UI 而不阻塞它并让其他对象在后台运行并根据需要向主线程返回值的推荐方法是什么。我知道如何使用块,但不允许块操作返回值。 我需要的是帮助这个伪代码的东西:
-(IBAction) main {
//Update progress indicator UI to show progress
//perform an call to another object from another class.
// wait till i get its return value.
//Update progress indicator UI to show progress
// Use this return value to do something.
//Update progress indicator UI to show progress
}
当调用另一个对象时,我注意到我已经完全消失了确定的 NSProgressIndicator,因为主线程被阻塞了。谢谢。
【问题讨论】:
标签: objective-c multithreading nsprogressindicator