Ian*_*ink 3 iphone multithreading xamarin.ios
iPHone:我们使用MonoTouch,但Obj-C答案还可以.
我的单例域对象需要一段时间来获取所有数据,因此它在内部运行部分线程中的提取.
我需要通知UI域已完成.目前我这样做.有没有更好的办法?在WinForms中,我将调用Application.DoEvents()而不是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 ();
Run Code Online (Sandbox Code Playgroud)
只是为了跟进Lounges回答,这是一个C#代码示例:
NSRunLoop.Current.RunUntil(DateTime.Now.AddMilliseconds(2000));
Run Code Online (Sandbox Code Playgroud)
这将暂停2000毫秒,但确保UI更新.我只是在一些测试代码中使用它.
| 归档时间: |
|
| 查看次数: |
4495 次 |
| 最近记录: |