我可以使用多线程加载网格 [英] Can I use multithread to load a grid

查看:75
本文介绍了我可以使用多线程加载网格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个C#windows应用程序。在一种形式中,它有4个面板(启用自动隐藏),其中有网格。在加载表格时,我正在填写网格(根据客户的要求)。一个网格具有大量数据,并且比预期花费更多时间加载,并且用户必须等待所有时间。现在,我怀疑的是,我是否可以使用多线程来加载特定的网格?

我听说使用多线程的UI元素不是一个好习惯。任何人都可以给我一个建议,还是有其他选择做同样的事情?



提前谢谢

I am developing a C# windows application. In one form, it has 4 panels(autohide enabled) with grids in it. On load of the form I am filling the grids (As per client's requirement). One grid is having large amount of data and is taking more time to load than expected and the user has to wait all that time. Now, my doubt is, whether I can use multithreading for loading that particular grid??
I heard that using multithread for UI elements is not a good practice. Can anyone give me a suggestion or is there any other option for doing the same??

Thanks in advance

推荐答案

是的,您可以使用多线程。您应该注意的唯一事情(实际上是其中之一)是无法从主线程以外访问用户界面(表单或表单及其控件)。



您的工作线程可以加载数据(它应该是缓慢的部分)并使用adhook的一种方法通知主线程。看看周围的许多样本 Form.Invoke()
Yes, you can use multi-threading. The only thing (well, in fact one among many others) that you should take care is not having access to user interface (the form or forms and its controls) from other than the main thread.

Your worker thread could load the data (the supposedly slow part of it) and notify the main thread using one method made adhook. Take a look into the many samples around there about Form.Invoke().


hi,



查看此链接



在DataGridView中加载十亿行 [ ^ ]



http://social.msdn.microsoft.com/论坛/ windows / en-US / 2bd3d0a0-22e6-4782-93dc-a49aa344d307 /如何加载数据网格快速 [ ^ ]







希望这可以帮到你



快乐编码:)


check this link

Load a billion rows in a DataGridView[^]

http://social.msdn.microsoft.com/Forums/windows/en-US/2bd3d0a0-22e6-4782-93dc-a49aa344d307/how-to-load-the-datagridview-fast[^]



Hope this helps you

Happy coding :)


这篇关于我可以使用多线程加载网格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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