what is looping in computer ?

2007-04-14 1:04 am
what is looping in computer ?

回答 (30)

2007-04-14 2:04 am
✔ 最佳答案
In computing, the main loop (sometimes called the program loop, event loop or main event loop) is a common design approach, typically used by applications featuring an event driven graphical user interface. It consists of a loop which continuously executes, polling for user events and handling each one. After handling the event in whatever manner is appropriate, control returns to the loop until another event is received, and so on. The loop is at the highest level of control within the program, hence 'main'.
This approach is in contrast to a number of other alternatives:

Traditionally, a program simply ran once then terminated. This type of program was very common in the early days of computing, and lacked any form of user interactivity. This is still used a lot, particularly in the form of command line driven programs. Any parameters are set up in advance and passed in one go when the program starts.
Menu-driven designs. These still may feature a main loop but are not usually thought of as event driven in the usual sense. Instead, the user is presented with an ever-narrowing set of options until the task they wish to carry out is the only option available. Limited interactivity through the menus is available.
Most modern applications feature a main loop, though in contrast to earlier designs, the use of preemptive multitasking means that the loop is often stopped, and is only restarted when there is actually something ready for it to process. This is more efficient than the use of polling, which was the usual approach when cooperative multitasking was used.
This pseudocode shows a typical application main loop:
begin( my_program )
initialize_everything;
mainloop:
event = next_event;
process_event( event );
if ( event = quit )
terminate;
else
goto mainloop;
end;
2007-05-01 8:50 pm
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 5:25 pm
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 12:07 pm
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 10:30 am
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 8:53 am
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 8:34 am
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 5:41 am
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。
2007-04-26 5:09 am
本盟一視同仁,盟友與其他人同罪,現以此作懲處,望你回頭是岸。


收錄日期: 2021-04-12 19:27:30
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070413000051KK03822

檢視 Wayback Machine 備份