问题描述
什么是VB6的的DoEvents在.NET中的等价?
What's the equivalent of the VB6's DoEvents in .NET?
编辑:
我有一子,需要一个很长的时间来完成其工作。 (它有一个做一段时间),当我把它称为,形式变为白色。在VB6中我曾经把一个调用DoEvents的方法(在其DO-同时),以prevent这一点。
I have a Sub that takes a long time to do its work. (it has a do-while) when I call it, The form turns white. in VB6 I used to put a DoEvents in the method (inside its do-while) to prevent this.
推荐答案
有几个(如果有的话)的情况下,其中的DoEvents是.NET的解决方案。如果您张贴一些有关你在做什么,我们可能有一些建议,以替代。
There are few (if any) cases in which DoEvents is the right solution in .NET. If you post a little about what you're doing, we might have some suggestions as to an alternative.
在回答您的编辑,你需要做的就是创建一个BackgroundWorker.这将让你的主(GUI)线程自由,允许其重新绘制和行为正常。有很多教程在网络这个上,包括this 之一。
In response to your edit, what you need to do is create a BackgroundWorker. This will keep your main (GUI) thread free, allowing it to repaint and behave normally. There are many tutorials on the web for this, including this one.
这篇关于在.NET中的DoEvents的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!