如何在GUI中管理多线程...? [英] How to manage multithreading in GUI...?

查看:83
本文介绍了如何在GUI中管理多线程...?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我正在使用MySql 5.0作为DB在C#.NET(2.0)中为一家公司编写中级应用程序.
我面临的主要问题是加载GUI窗口的延迟.
GUI窗口充满了约30个组件的控件.其中大约一半是数据绑定控件.因此,当窗口加载时,用户会遭受5秒钟的延迟.我现在想的只是实现多线程.第一个线程用于加载数据绑定,第二个线程用于显示UI;第二个线程用于显示UI.但是我很高兴.因为,我在其中进行数据绑定的线程不允许我访问GUI组件,因为这些组件是在另一个线程中创建的.请尽快在这种情况下为我提供帮助.
提前感谢!
-Satyam

Hi,
I''m making a middle level application for a firm in C#.NET (2.0) with MySql 5.0 as DB.
The main problem i''m facing is the latency in loading the GUI window.
The GUI window is full of Controls about 30 components. About half of them are data binding controls. So, when the window loads, the user suffers the latency of 5 seconds. All I''m thinking right now is to implement multithreading. The first thread is for loading the data binding and second one is to show the UI; but i''m in vein. Because, the thread in which i do the databinding don''t allow me to access the GUI component coz the components were created in another thread. Please help me in this scenario asap.
Thanx in advance!
-Satyam

推荐答案

您可以使用InvokeRequired Dispatcher .
You can launch a thread on the GUI thread from another thread with InvokeRequired and Invoke. That''s if you are using Windows Forms. If you are using WPF, you can do the same thing with the Dispatcher.


这篇关于如何在GUI中管理多线程...?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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