来讲一讲事件
何谓事件?
事件是可以由程序检测到的动作或发生的事情。典型的事件则与程序流同步处理,也就是程序有哪里处理事件的一个或多个专用的地方,常常指一个事件循环。
典型事件的来源包括用户(谁按下一个键上的键盘)。另一个来源是一个硬件设备,如定时器。
任何程序都可以自定义设置触发事件的事情,如完成通信任务。改变其行为响应于事件的函数(被认为是事件驱动的),事件常常具有与目标互动的功能。
以上翻译自维基百科Event (computing) 词条,因是英文,所以有一些语句不通顺,特附上原文:
In computing, an event is an action oroccurrence detected by the program that may be handled by the program.Typically events are handled synchronously with the program flow, that is, theprogram has one or more dedicated places where events are handled, frequentlyan event loop. Typical sources of events include the user (who presses a key onthe keyboard, in other words, through a keystroke). Another source is ahardware device such as a timer. Any program can trigger its own custom set ofevents as well, e.g. to communicate the completion of a task. A computerprogram that changes its beha