Application.doevents (): Handles all Windows messages currently in the message queue.
Private void button1_click (object sender, EventArgs e) { for (int0 10000; i++) { = i.tostring (); Application.doevents (); } }
Test, there is no application.doevents (), the label is basically in a false state, the last display of a 9999, plus the number will be converted to normal display.
From this test after the DoEvents function, should be doevents like to achieve the synchronization of the process. At no time, because of the priority problem, the program will execute the main process code, and then execute the code, and add the later can be executed synchronously.
Hand over the CPU control so that the system can process all Windows messages in the queue, such as in a large computation cycle, plus application.doevents to prevent the interface from stopping responding , Because the WinForm message loop is handled by a newly created thread, if one of your operations is time-consuming, the message is processed so that you can continue to do so after you have done this time-consuming operation. The Application.doevents method is to allow you to invoke it within the time-consuming operation and to process messages in the message queue. Like a mouse mouse click is a Windows message, if the time-consuming operation has been done, then the interface is like a deadlock.
while (true) { application.doevents (); // }
Citation connections:
the role of Application.doevents ()the role of Application.doevents () in C #winform-application.doevents ()
Disadvantages of using application.doevents ():
Http://blogs.msdn.com/b/jfoscoding/archive/2005/08/06/448560.aspx
The role of Application.doevents ()