Windows 窗体应用程序是否忙于等待用户输入?
通常,Windows 窗体应用程序会在用户给出输入时继续执行。
例如:单击按钮。
在那之前应用程序是否忙于等待?
(去检查“按钮”是否已被“单击”。我的意思是检查是否发生了任何事件)
或者当事件发生时操作系统是否会中断应用程序?
Windows 窗体应用程序的确切事件处理机制是什么?
Normally windows forms applications proceeds execution as the user gives the input(s).
ex : Click a Button.
Until then does the application busy waits ?
(go and check whether "a button" has been "clicked".I mean check if any event has occured)
or when an event occurs does the OS interrupts the applications ?
What is the exact event handling mechanism for Windows forms applications ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不,他们不会忙着等待:他们运行一个 Windows 消息泵,这是一个循环,直到 Windows 有消息要提供给它为止。
这基本上就是 Application.Run做。
No, they don't busy wait: they run a Windows Message Pump that is a loop which blocks until Windows has a message to give to it.
This is basically what Application.Run does.
我对此没有太多了解可以分享。但肯定会分享我的花生。
程序不等待任何人。就像处于睡眠模式一样。确实消耗资源,但只是为了将其 GUI 保留在屏幕上。
事件处理不是基于程序或基于操作系统的。它基于硬件。当您单击鼠标或按下键盘上的某个键时,它被视为异步外部活动。硬件向操作系统通报用户或外部设备所采取的操作,并将信息传递给相应的程序。程序可以接受密钥或拒绝它。如果接受,则密钥将传递给事件处理程序并生成所需的操作。操作系统根本不参与该过程。它或多或少就像一个将本机代码转换为程序可读代码的中介。这就是程序特定于操作系统的原因之一。我的意思是,如果操作系统将本机代码转换为程序无法读取的格式怎么办?
您正在谈论基于 Windows 的应用程序中的事件,让我们想象一下 USB 的情况。现在的主板上有8个或8个以上的USB插槽。用户可以将 USB 插入任何插槽。操作系统是否一直等待 USB 插入,并且在每个插槽中一直跟踪和等待?不。一点也不。它是一个基于硬件的过程,硬件有责任向操作系统通报它。 Windows 兼容和 Linux 兼容社区出现在这里,他们讨论哪个硬件是哪个操作系统支持的。
查看此内容了解更多信息。
I don't have much knowledge about it to share. But surely will share my peanuts.
Program does not wait for any one. Its like in sleep mode. Does consume resource but just to keep its GUI on screen.
Event handling are not Program based or OS based. Its hardware based. When you click your mouse or press a key on keyboard, its considered to be Asynchronous External activity. Hardware intimates the OS about the action taken by the user or a external device and the information is passed to the the corresponding Program. The Program can accept the Key or reject it. If it accepts, the key is passed to the Event handlers and required action is generated. OS is not at all involved in the process. Its more or less like a mediator which converts the Native Code into Program readable Code. And that is one of the reason the programs are OS specific. I mean what if OS converts Native Code in a format which program can not read??
You are talking about a Event in Windows based application, lets imagine the case of USB. There are 8 or more than 8 USB slots in the motherboards today. A user can plug the USB in any slot. Do OS keep waiting that a USB will be inserted and in every slot it keep tracking and waiting?? NO. Not at all. Its a hardware based process and its the duty of hardware to intimate OS about it. Windows Compatible and Linux Compatible communities come in to picture here, where they discuss that which hardware is which OS supported.
See this to know more.