GUI编程技巧(不是布局设计) [英] GUI Programming Tips (not layout design)

查看:84
本文介绍了GUI编程技巧(不是布局设计)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在慢慢地从商业用户转移到房子的dba /编码方面。我已经在Access中编写了自动化脚本,我现在正致力于使用Visual Studio创建C#GUI以与我们的SQL服务器表接口。



随机地,我遇到了一个使用后台线程处理按钮点击等工作量的线程。我想知道是否还有其他标准技术像这样用于编码GUI。当我google或搜索论坛时,我发现的一切都是关于GUI的可视化布局(从作为业务用户,我一直是客户,所以我对GUI布局有了一个想法(我认为......))。



感谢您对我的回答问题......就像我说的那样,我对这整个编码事情都很陌生,到目前为止我很喜欢它。 。

I'm slowly moving from a business user to the dba/coding side of the house. I've written automation scripts in Access over the last few and am now working on making C# GUIs with Visual Studio to interface with our SQL server tables.

Randomly, I came across a thread on using background threads to handle the workload for things such as button clicks, etc. I was wondering if there were any other standard techniques like this that are used in coding for GUIs. When I google or search forums, everything I find is about visual layout of the GUI (from being a business user, I've been the customer, so I have an idea about GUI layouts (I think...)).

Thank you for bearing with my round about question... like I said, I'm new to this whole coding thing, and am loving it so far...

推荐答案

问题太模糊了。 标准技术?



在UI中使用附加(非UI)线程的技术与UI线程调用有关。您不能从非UI线程调用与UI相关的任何内容。相反,您需要使用 Invoke System.Windows.Threading的方法。 Dispatcher (对于Forms或WPF)或 System.Windows.Forms.Control (仅限表单)。



您将在我过去的答案中找到有关其工作原理和代码示例的详细说明:

Control.Invoke()与Control.BeginInvoke() [ ^ ],

使用Treeview扫描仪和MD5的问题 [ ^ ]。



另请参阅有关线程的更多参考资料:

如何让keydown事件在不同的操作上运行vb.net中的线程 [ ^ ],

在启用禁用+多线程后控制事件未触发 [ ^ ]。



-SA
The question is too vague. "Standard techniques"?

The technique of using additional (non-UI) threads in UI is related to UI thread invocation. You cannot call anything related to UI from non-UI thread. Instead, you need to use the method Invoke or BeginInvoke of System.Windows.Threading.Dispatcher (for both Forms or WPF) or System.Windows.Forms.Control (Forms only).

You will find detailed explanation of how it works and code samples in my past answers:
Control.Invoke() vs. Control.BeginInvoke()[^],
Problem with Treeview Scanner And MD5[^].

See also more references on threading:
How to get a keydown event to operate on a different thread in vb.net[^],
Control events not firing after enable disable + multithreading[^].

—SA


这篇关于GUI编程技巧(不是布局设计)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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