[Turn] C # Application.DoEvent () action

Role Application.DoEvents (): The current Windows handles all the messages in the message queue.

private void button1_Click(object sender, EventArgs e)  
{  
    for (int i = 0; i < 10000; i++)  
    {  
        label1.Text = i.ToString();  
        Application.DoEvents();  
    }  
}  

Test it, no Application.DoEvents () when, Label basically in a fake crash state, and finally a 9999 display, plus the normal display after the digital conversion.

From DoEvents function after this test, DoEvents should like to achieve the synchronization process. Without the addition of time, because the priority of the problem, the program will execute the code of the primary process, and then execute other code, and add after running simultaneously.

Original link: https: //www.cnblogs.com/wuhanly/p/5228765.html

Guess you like

Origin www.cnblogs.com/wodewei/p/11532779.html