Winform |解密和在datagridview中加载数据|慢的 [英] Winform | decrypt & load data in datagridview | slow
问题描述
我将尽力解释所有事情,以免错过任何重要的事情.
Winform-.NET 4.0 DataGridView
使用BindingSource
加载25000行绑定到Datagridview的数据
在总计50条内容的列中,有7列具有加密数据(河豚)
数据加载完成后-循环所有行以解密信息
这需要9分钟的时间
需要帮助:
缩短加载时间
不允许选择任何字段
也必须加载全部25000
我想我已经尝试了很多方法来达到这一点,但是我想我需要一些方法来弄清最后一点.我的一些朋友说,他们可以使用WPF集合(每分钟25万条记录)加载数据.我不知道这是否正确,但这是一个VB.NET Winform应用程序-请提出我可以尝试加快应用程序加载时间的任何建议.
非常感谢.
我尝试过的事情:
1.延迟加载-使用后台工作程序解密数据表中的记录.当前,此方法有效并有助于使UI保持响应状态,但除非解密完成,否则用户无法导出数据.需要阿波克斯. 8分钟即可完成.
2.硬加载-使用
Hi,
I will try and explain everything so that I do not miss out on anything important.
Winform - .NET 4.0 DataGridView
Loading 25000 rows of data which is bound to a Datagridview using BindingSource
Out of a total 50 something columns, 7 columns have encrypted data (Blowfish)
After the data load is complete - looping all rows to decrypt info
This takes a whopping 9 minutes
Help needed to:
Bring the loading time down
Exclusion of any field is not an option
Loading all 25000 is also a requirement
I think I have tried a lot of methods to reach to this point, but I think I need some to figure the last bit out. Some of my friends said they could load data using WPF collections (0.25 million records per minute). I do not know if that''s true but this being a VB.NET Winform app - please suggest anything I can try to speed up the application load times.
Many thanks.
What I have tried:
1. Lazyloading - uses a Background worker to decrypt records in datatable. This currently works and helps keep the UI responsive but the user cannot export the data unless the decryption is complete. Takes appox. 8 mins to complete.
2. Hardloading - Using
Parallel.ForEach
遍历Datatable中的所有记录.这样可以在一半时间(即4分钟)内完成工作,但UI有时会变得无响应.另外,CPU使用率达到100%.使用MaxDegreeOfParallelism作为变量,但使用2以上的值将冻结GUI.
3.大量加载-通常使用
looped through all records in Datatable. This completes the job in half the time i.e. 4 mins but the UI becomes unresponsive at times. Also the CPU usage goes to 100%. Used MaxDegreeOfParallelism as a variable but using anything above 2 freezes the GUI.
3. Eagerloading - normally loop through all records in Datatable using
For Each
大约需要9分钟才能完成.
This takes about 9 mins to complete.
推荐答案
将25000个项目加载到用户界面中只是愚蠢的事情.这是我可以说的最谨慎的方法.
WPF集合?我想你的朋友在说垃圾.
如何加快加载时间?
1.您应该实现某种分页-例如,仅加载前40个项目,直到用户按下Page Down
2.将数据加载到.NET集合(例如列表)中.您可能需要创建一个反映传入数据的类.
3.遍历该集合,而不要遍历任何UI控件.
4.使用JIT思维-仅在尝试显示时才解密-一次只能存储40条记录.
最好的建议是在工作线程上分页.
顺便说一句-从来没有任何充分的理由将这么多的行加载到UI组件中.
Loading 25000 items into a User Interface is just silly. That is the politest way I can put it.
WPF collections? I think your friends are talking rubbish.
How to speed up the load times?
1. You should implement some sort of paging - for example only load the first 40 items until the User presses Page Down
2. Load the data into a .NET collection - for example a List. You may need to create a class that reflects the incoming data.
3. Iterate through the collection not any UI control.
4. Use JIT thinking - only decrypt when attempting to display - so only 40 records at a time.
Best advice would be paging on a worker thread.
By the way - There is never any good reason to load that many rows into a UI component.
这篇关于Winform |解密和在datagridview中加载数据|慢的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!