本文介绍了Application.DoEvents()是多任务处理的一种形式吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我非常确定 Applicataion.DoEvents ()在Windows窗体中.是一种非常早期,非常原始的WindowsForms多任务处理形式.它具有所有的讲故事和技巧:

I am pretty sure Applicataion.DoEvents() in Windows Forms. is a very early, very primitive, WindowsForms only form of Multitasking. It has all the telltales and mechanics:

  • 暂停执行调用事件.
  • 使上述Event的其余部分继续运行,以便稍后运行.
  • 允许其他事件/进程运行.只是有一些额外的问题,因为MT是通过EventQueue实现的.甚至可能递归调用队列.

但是我只是遇到一个坚持与多任务无关"的人,这与我对功能或多任务的理解不一致.

But I just ran into a person that insists it has "nothing to do with Multitasking", which I cannot reconcile with my understanding of the Function or the of Multitasking.

注意:我明确认为Mutlti 线程仅是Multi 任务的一种实现.显然,DoEvents()不是多线程的一种形式,众所周知,那个线程有多糟糕在GUI环境中工作.

Note: I explicitly consider Mutltithreading only an implementation for Multitasking. It is clear that DoEvents() is not a form of Multithreading, as we all know how poorly that one works in GUI Environments.

推荐答案

除了猜想它仅适用于WinForms之外,您几乎在所有方面都可以纠正. "DoEvents"在WinForms之前;它早在发明WinForms之前就已存在于Visual Basic中,并且泵送消息队列"显然也早于VB.而且这是一个坏主意,也很容易被滥用.

You are pretty close to correct on all counts except for your conjecture that it is for WinForms only. "DoEvents" precedes WinForms; it was present in Visual Basic long before WinForms was invented, and "pump the message queue" obviously precedes VB also. And it was a bad idea and easily abused then too.

DoEvents实际上并没有像await这样的方式使任何东西延续.调用DoEvents时,无论当前正在运行"的任何事件在堆栈中都有其状态,在这种情况下,堆栈是延续的实现.这是针对DoEvent的另一点-与await不同,它吞噬了堆栈,因此可能导致溢出.

DoEvents doesn't really make anything into a continuation the way that say, await does. Whatever event is currently "in flight" when DoEvents is called has its state on the stack, and the stack is the implementation of continuation in this case. This is another point against DoEvents -- unlike await, it eats stack, and therefore can contribute to an overflow.

那你应该请作者澄清一下,因为这听起来肯定是错误的.

You should ask the author for clarification then, since that certainly sounds wrong.

这篇关于Application.DoEvents()是多任务处理的一种形式吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-27 14:33