加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

在没有DoEvents的VB6.0中取消长时间运行的过程?

发布时间:2020-12-16 23:55:59 所属栏目:大数据 来源:网络整理
导读:是否可以在VB6.0中取消长时间运行的进程,而不使用DoEvent? 例如: for i = 1 to someVeryHighNumber ' Do some work here ' ... if cancel then exit for end ifnextSub btnCancel_Click() cancel = trueEnd Sub 我假设我需要一个“DoEvents”之前的“如果
是否可以在VB6.0中取消长时间运行的进程,而不使用DoEvent?

例如:

for i = 1 to someVeryHighNumber
    ' Do some work here '
    ...

    if cancel then
        exit for
    end if
next

Sub btnCancel_Click()
    cancel = true
End Sub

我假设我需要一个“DoEvents”之前的“如果取消然后…”有更好的方法吗?有一阵子了…

不,你说得对,你肯定想要你的循环中的DoEvents。

如果将DoEvents放在主循环中,发现处理速度太慢,请尝试调用Windows API函数GetQueueStatus(这比DoEvents快得多)来快速确定是否有必要调用DoEvents。 GetQueueStatus告诉你是否有任何事件要处理。

' at the top:
Declare Function GetQueueStatus Lib "user32" (ByVal qsFlags As Long) As Long

' then call this instead of DoEvents:
Sub DoEventsIfNecessary()
    If GetQueueStatus(255) <> 0 Then DoEvents
End Sub

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读