关于DOEVENTS()的问题

iwin 2000-08-09 03:43:00
有一个函数A()中要执行很长的计算,里面有DoEvents()语句。现在我想当出现重入A()时,停止重入之前A()中的操作,并运行当前重入的操作。
...全文
229 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
iwin 2000-08-10
  • 打赏
  • 举报
回复
谢谢wulang的例子,但我认为你的例子并不符合我的要求,它并没有结束第一次进入函数A()的线程。
iwin 2000-08-09
  • 打赏
  • 举报
回复
wulang:
我没有收到你的例子,请再发一次好吗?
wulang 2000-08-09
  • 打赏
  • 举报
回复
应该是可以的,关键是在重入之前退出A()。
我给你发了一个小例子,看对你有没有用。
xlzhou 2000-08-09
  • 打赏
  • 举报
回复
DoEvents equals

if(PeekMessage(...))
{
GetMessage(...);
DispatchMessage();
}

Because Visual Basic use COM model, and it must be the single threaded apartment, any time only a thread can be scheduled. So if you don't use DoEvents in Function A, the calling A will be put into the message queue, but you don't call Doevents statement the thread have no time to pick up the message queue, the function can't be reentered.

However, if you call the Doevents statement, the Function A will be reentered, but you should remember VB is a single threaded app, so the former entering will no be executing until the reenter one ended.

7,762

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧