在BindingList C#WinForms中定位对象 [英] Locating objects in BindingList C# WinForms

查看:150
本文介绍了在BindingList C#WinForms中定位对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个异步BindingList,其中包含在工作线程上进行操作并绑定到Main UI线程上的BindingSource以及绑定到DataGridView的BindingSource的对象.
是否有可能在不迭代列表的情况下在我的BindingList中定位对象?

我看过LINQ的内幕,它基本上是涂有糖衣的foreach循环.另外据我了解,如果我实现IBindingList.Find(),它仅是一个for循环...

我已经尝试"将我的BindingList同步/映射到镜像我的BindingList的Dictionary,并使用Dictionary定位对象并将结果(索引)传递给我的BindingList,但这不起作用,因为添加和添加的内容过多删除对象,我无法使事情井井有条.

这是一款高性能应用,可处理来自股市的实时高频数据.这就是为什么我无法遍历BindingList的原因,它效率太低.

有人可以给我一些建议和/或解决方案吗?

预先感谢,
-DA

I have an Asynchronous BindingList that contains objects that are manipulated on a worker thread and bound to a BindingSource on the Main UI thread with a BindingSource bound to a DataGridView.

Is there anyway possible to locate objects in my BindingList without iterating through the list?

I''ve looked under the hood of LINQ and it''s basically a sugar coated foreach loop. Also from my understand if I implement IBindingList.Find() it''s nothing more than a for-loop...

I''ve "tried" to synchronize/map my BindingList to a Dictionary that mirrors my BindingList and using the Dictionary to located objects and pass the results(index) to my BindingList but this is not working because there is just too much adding and removing of the objects and I can''t keep things organized.

This is a high-performance app that''s dealing with real-time high frequency data from the stock market. That''s why I can''t iterate through the BindingList, it''s just too inefficient.

Can someone please give me some advice and/or solutions.

Thanks in advance,
-DA

推荐答案

我认为这会有所帮助

例如,您有一个人员列表,并且有一个ID,则需要找到ID = 1000
的人员.

I think it helps

For example you have a List of Person and you have an ID and you need to locate a Person where ID = 1000


var foundPeople = myList.TakeWhile(p => p != 1000);
int index = foundPeople.Count();


这篇关于在BindingList C#WinForms中定位对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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