The role of Application.doevents ()

Source: Internet
Author: User

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 ()

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.