本文介绍了DoEvents的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以附上我的代码,如果有人想看到它,但我会先尝试用一些标记代码询问我的

问题。


我在使用DoEvents时遇到问题终止我的进程。对于

示例:


Button.text = start


如果button.text = start则

button.text = stop

msgbox" Boo!"

doevent

而1 = 1

msgbox" BooHoo! 

loop

else if button.text = stop

button.text = start

msgbox" Quit Your Whining"

结束如果

好​​的,点击按钮就可以得到:

Boo!

BooHoo!

BooHoo!

BooHoo!

BooHoo!

BooHoo!

BooHoo!

.......


现在点击停止按钮即可获得


退出你的抱怨

BooHoo!


这没有意义。按钮已经没有=开始。这是停止

这就是为什么它运行停止代码。


由于某种原因它最后一次通过DoEvents代码。


如何在运行我的STOP代码之前正确停止DoEvents线程?


感谢您的任何建议!

I can attach my code if anyone wants to see it however I''ll try to ask my
question with some mark up code first.

I''m having a problem terminating my process while using DoEvents. For
example:

Button.text = start

If button.text = start then
button.text = stop
msgbox "Boo!"
doevent
while 1=1
msgbox "BooHoo!"
loop
else if button.text = stop
button.text = start
msgbox "Quit Your Whining"
end if
Ok, click the button and you get:
Boo!
BooHoo!
BooHoo!
BooHoo!
BooHoo!
BooHoo!
BooHoo!
.......

Now click the stop button and you get

Quit Your Whining
BooHoo!

That doesn''t make sense. The button already did NOT = Start. It was Stop
which is why it ran the stop code.

For some reason it goes through the DoEvents code one last time.

How can I properly stop that DoEvents thread prior to running my STOP code?

Thanks for any advise!

推荐答案



< snip>

<snip>



< snip>


我不认为你的标记翻译了你的行动序列>
代码非常忠实。例如,标记代码只调用DoEvents

一次,看起来你期望它运行几次。也许

修改标记或发布实际代码会提供更好的问题视图。


请记住,然而,VB.Net中的DoEvents可能比VB经典更危险/不可预测/不可判坏,因为VB.Net

必须考虑到更多的东西。事件处理周期。对于

示例,启动DoEvents执行

线程间UI更新时来自meain线程,你可能会崩溃应用程序。


还有其他方法来实现你(似乎)想要,并且

DoEvents就在这个列表中,即使在那里也是如此。


HTH。


问候,


布兰科。

<snip>

I don''t think your markup translates the sequence of actions from your
code very faithfully. For instance, the markup code only calls DoEvents
once, and it seems you''re expecting it to run several times. Maybe
revising the markup or posting the actual code would provide a better
view of the problem.

Keep in mind, however, that DoEvents in VB.Net can be even more
dangerous/unpredictable/undebuggable than in VB classic, cause VB.Net
must account for many more things in the event processing cycle. For
Example, launch a "DoEvents" from the meain thread when performing
inter-thread UI updates and you may crash the application.

There are other ways to accomplish what you (seem to) want, and
DoEvents is way down in this list, if even there at all.

HTH.

Regards,

Branco.






这篇关于DoEvents的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-15 10:22