是Application.DoEvents()只为的WinForms? [英] Is Application.DoEvents() just for WinForms?

查看:168
本文介绍了是Application.DoEvents()只为的WinForms?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Application.DoEvents()只是形式?

我认为这个命令是用来确保所有之前被处理的命令,但现在在读的文档,我不知道了。

I thought that this command was used to ensure that all of the commands before are processed but now after reading the documentation, I'm not sure anymore.

推荐答案

是的,它的真正目的在于Windows窗体。然而,在我看来,应该尽可能地避免。

Yes, it's really aimed at Windows Forms. However, in my view it should be avoided where possible.

它通常用来作为一个黑客通过谁不希望与把长时间运行的操作在不同的线程困扰开发人员......但是这意味着他们引进重入问题可以是很难跟踪下来,以及仍然阻塞UI线程一段的时间(如果其包括类似的文件操作,可以不真正predict操作是否将完成足够快地没有用户可见效果)

It's usually used as a hack by developers who don't want to be bothered with putting long-running operations on a different thread... but that means they're introducing re-entrancy issues which can be very hard to track down, as well as still blocking the UI thread for some of the time (and if that includes something like a file operation, you can't really predict whether the operation will complete quickly enough to not have a user visible effect).

这篇关于是Application.DoEvents()只为的WinForms?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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