关于DoEvents的大辩论 [英] The big Debate on DoEvents

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

问题描述

好的全部,


我有一个程序从串口接收信息。

偶尔这个信息要求我举起一个事件并更新

a progressbar告诉我收到了多少信息。

我的问题就在那里。当我更新进度条时,我需要更新

显示.... progressbar.refresh,漂亮又简单,但是,如果

用户点击屏幕上的任何一点从串口接收信息

时,整个程序似乎锁定....

屏幕变白,直到信息完成接收

串口信息。因此,我在更新进度条后实现了

Application.doevents()。这完全放慢了整个过程的速度。我收到的信息需要大约1分钟的时间才能收到,但是在DoEvents调用时需要花费两倍

...这是不可接受的!


有没有人知道如何加快速度,同时保持

表格还活着?我不能让我的用户在屏幕上方的

顶部看到(没有响应)我没有时间花费时间来获得
收到任何双倍的东西!


请帮忙!


谢谢


Dave

Ok All,

I have a program that receives information from the serial port.
Occasionally this information requires me to raise an event and update
a progressbar telling me how much of the information I have received.
My problem lies there. When i update the progressbar, I need to update
the display.... progressbar.refresh, nice and simple, however, if the
user clicks on the screen at any point whilst receiving information
from the serial port, the whole program appears to lock up.... the
screen goes white until the information has completed receiveing
information on the serial port. I therefore implemented an
Application.doevents() after updating the progressbar. This has slowed
the whole process down completely. The information I receive takes
about 1 minute to receive, however with a DoEvents call it takes twice
as long.... this is not acceptable!

Does anyone have any idea how to speed this up whilst also keeping the
form alive? I can''t allow my users to see a (not responding) at the
top of the screen and I can''t afford to have the time it takes to
receive anything double!

Please help!

Thanks

Dave

推荐答案

2006年6月14日01:21:14 -0700,Dave <哒******* @ gmail.com>写道:
On 14 Jun 2006 01:21:14 -0700, "Dave" <da*******@gmail.com> wrote:
Ok All,

我有一个程序从串口接收信息。
有时候这些信息要求我举办活动并更新
一个进度条告诉我我收到了多少信息。
我的问题就在那里。当我更新进度条时,我需要更新显示.... progressbar.refresh,简单明了,但是,如果
用户在接收信息的任何时候点击屏幕
从串口,整个程序似乎锁定....
屏幕变白,直到信息完成接收串口上的信息。因此,我在更新进度条后实现了一个
Application.doevents()。这已经完全放慢了整个过程的速度。我收到的信息需要大约1分钟才能收到,但是通过DoEvents调用它需要两次
...这是不可接受的!

有没有人有任何信息想法如何加快速度,同时保持
形式的活力?我不能允许我的用户在屏幕顶部看到(没有响应),我没有时间花点时间来收到任何双倍的东西!

请帮忙!

谢谢

戴夫
Ok All,

I have a program that receives information from the serial port.
Occasionally this information requires me to raise an event and update
a progressbar telling me how much of the information I have received.
My problem lies there. When i update the progressbar, I need to update
the display.... progressbar.refresh, nice and simple, however, if the
user clicks on the screen at any point whilst receiving information
from the serial port, the whole program appears to lock up.... the
screen goes white until the information has completed receiveing
information on the serial port. I therefore implemented an
Application.doevents() after updating the progressbar. This has slowed
the whole process down completely. The information I receive takes
about 1 minute to receive, however with a DoEvents call it takes twice
as long.... this is not acceptable!

Does anyone have any idea how to speed this up whilst also keeping the
form alive? I can''t allow my users to see a (not responding) at the
top of the screen and I can''t afford to have the time it takes to
receive anything double!

Please help!

Thanks

Dave




从我自己的经验到目前为止,比较它在VB6中使用,

网中的DoEvents()似乎不起作用,我假装它甚至不存在


但是,你所描述的情况是一个典型的例子,它应该在一个单独的线程中运行,并且是一个

开始的好地方如果你不熟悉线程。


Gene



From my own experiences thus far, compared to it''s use in VB6,
DoEvents() in Net does not seem to work and I pretend it doesn''t even
exist.
However, the situation you are describing is a classic example of a
process that should be running in a separate thread and would be a
good place to start if you''re not familiar with Threads.

Gene




Dave,


在循环中添加一个


Threading.thread.sleep(毫秒)


Cor


" Dave" <哒******* @ gmail.com> schreef in bericht

news:11 ********************* @ y41g2000cwy.googlegro ups.com ...

Dave,

Add a

Threading.thread.sleep(milliseconds) in the loop

Cor

"Dave" <da*******@gmail.com> schreef in bericht
news:11*********************@y41g2000cwy.googlegro ups.com...
好的全部,

我有一个程序从串口接收信息。
有时这个信息要求我举一个活动并更新
一个进度条告诉我如何我收到的很多信息。
我的问题就在那里。当我更新进度条时,我需要更新显示.... progressbar.refresh,简单明了,但是,如果
用户在接收信息的任何时候点击屏幕
从串口,整个程序似乎锁定....
屏幕变白,直到信息完成接收串口上的信息。因此,我在更新进度条后实现了一个
Application.doevents()。这已经完全放慢了整个过程的速度。我收到的信息需要大约1分钟才能收到,但是通过DoEvents调用它需要两次
...这是不可接受的!

有没有人有任何信息想法如何加快速度,同时保持
形式的活力?我不能允许我的用户在屏幕顶部看到(没有响应),我没有时间花点时间来收到任何双倍的东西!

请帮助!

谢谢

Dave
Ok All,

I have a program that receives information from the serial port.
Occasionally this information requires me to raise an event and update
a progressbar telling me how much of the information I have received.
My problem lies there. When i update the progressbar, I need to update
the display.... progressbar.refresh, nice and simple, however, if the
user clicks on the screen at any point whilst receiving information
from the serial port, the whole program appears to lock up.... the
screen goes white until the information has completed receiveing
information on the serial port. I therefore implemented an
Application.doevents() after updating the progressbar. This has slowed
the whole process down completely. The information I receive takes
about 1 minute to receive, however with a DoEvents call it takes twice
as long.... this is not acceptable!

Does anyone have any idea how to speed this up whilst also keeping the
form alive? I can''t allow my users to see a (not responding) at the
top of the screen and I can''t afford to have the time it takes to
receive anything double!

Please help!

Thanks

Dave



导致UI线程到通过在UI线程中调用Thread.Sleep来阻止

将延迟处理消息队列。最好是

避免Application.DoEvents并处理

另一个线程中的串口处理。


Brian


Cor Ligthert [MVP]写道:
Causing the UI thread to block by calling Thread.Sleep in the UI thread
will delay processing of the message queue. It really is better to
avoid Application.DoEvents and deal with the serial port processing in
another thread.

Brian

Cor Ligthert [MVP] wrote:
Dave,

添加

Threading.thread。在循环中睡觉(毫秒)

  < Dave" <哒******* @ gmail.com> schreef in bericht
新闻:11 ********************* @ y41g2000cwy.googlegro ups.com ...
Dave,

Add a

Threading.thread.sleep(milliseconds) in the loop

Cor

"Dave" <da*******@gmail.com> schreef in bericht
news:11*********************@y41g2000cwy.googlegro ups.com...
Ok全部,

我有一个程序从串口接收信息。
这个信息偶尔需要我举起一个事件并更新
一个进度条告诉我有多少信息我收到了。
我的问题就在那里。当我更新进度条时,我需要更新显示.... progressbar.refresh,简单明了,但是,如果
用户在接收信息的任何时候点击屏幕
从串口,整个程序似乎锁定....
屏幕变白,直到信息完成接收串口上的信息。因此,我在更新进度条后实现了一个
Application.doevents()。这已经完全放慢了整个过程的速度。我收到的信息需要大约1分钟才能收到,但是通过DoEvents调用它需要两次
...这是不可接受的!

有没有人有任何信息想法如何加快速度,同时保持
形式的活力?我不能允许我的用户在屏幕顶部看到(没有响应),我没有时间花点时间来收到任何双倍的东西!

请帮忙!

感谢

戴夫
Ok All,

I have a program that receives information from the serial port.
Occasionally this information requires me to raise an event and update
a progressbar telling me how much of the information I have received.
My problem lies there. When i update the progressbar, I need to update
the display.... progressbar.refresh, nice and simple, however, if the
user clicks on the screen at any point whilst receiving information
from the serial port, the whole program appears to lock up.... the
screen goes white until the information has completed receiveing
information on the serial port. I therefore implemented an
Application.doevents() after updating the progressbar. This has slowed
the whole process down completely. The information I receive takes
about 1 minute to receive, however with a DoEvents call it takes twice
as long.... this is not acceptable!

Does anyone have any idea how to speed this up whilst also keeping the
form alive? I can''t allow my users to see a (not responding) at the
top of the screen and I can''t afford to have the time it takes to
receive anything double!

Please help!

Thanks

Dave






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

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