从UI线程修改FXCollections.synchronizedObservableList [英] Modifying FXCollections.synchronizedObservableList out of the UI Thread

查看:163
本文介绍了从UI线程修改FXCollections.synchronizedObservableList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将 ListView 绑定到 SynchronizedObservableList 。我可以修改UI线程中的列表(添加删除等)吗?没有例外,但是UI正确同步了吗?

I've bind a ListView to a SynchronizedObservableList. Can I modify the list (add, remove, etc.) out of the UI Thread? There would be no exception but get the UI correctly synchronized?

推荐答案

否:如果可观察列表用于数据ListView(或ListView的数据绑定到它),然后它只应在FX应用程序线程上修改。

No: if the observable list is being used for the data for the ListView (or the data for the ListView is are bound to it), then it should only be modified on the FX Application Thread.

虽然使用同步列表提供了一些由于您已将 ListView 绑定到它,因此修改 synchronizedObservableList 将导致列表数据的同步保证 ListView 的属性(例如,它将导致其单元格发生更改)。 ListView 本身的属性没有同步保证,这些属性的任何更改都需要在FX应用程序线程上进行。

While using a synchronized list offers some synchronization guarantees on the list data, since you have bound the ListView to it, modifying the synchronizedObservableList will cause changes in the ListView's properties (for example, it will cause changes to its cells). There are no synchronization guarantees on the properties of the ListView itself and any changes to those properties need to occur on the FX Application Thread.

这篇关于从UI线程修改FXCollections.synchronizedObservableList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆