iPhone等效于Application.DoEvents(); [英] iPhone equivalent of Application.DoEvents();
本文介绍了iPhone等效于Application.DoEvents();的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
iPHone:我们使用MonoTouch,但是Obj-C的答案还可以.
iPHone: We use MonoTouch, but Obj-C answers are ok.
我的单例域对象需要一段时间才能获取所有数据,因此它在线程中内部运行部分提取.
My singleton domain object takes a while to get all the data so it runs internally parts of the fetch in a thread.
我需要通知UI该域已完成.目前,我正在这样做.有没有更好的办法?在WinForms中,我将调用Application.DoEvents()而不是Thread Sleep.
I need to inform the UI that the domain is done. Currently I do this. Is there a better way? In WinForms I would call Application.DoEvents() instead of Thread Sleep.
PlanDomain domain = PlanDomain.Instance ();
while (domain.IsLoadingData)
{
Thread.Sleep (100); //this is the main UI thread
}
TableView.Hidden = false;
TableView.Source = new TableSource (this);
TableView.ReloadData ();
推荐答案
通常来说,您想避免使用DoEvents. Objective-c中的iPhone等价物如下所示:
Generally speaking you want to avoid DoEvents. The iPhone equivilant in objective-c looks something like this:
[[NSRunLoop currentRunLoop] runUntilDate:[NSDate date]];
这篇关于iPhone等效于Application.DoEvents();的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文