Winforms Application.DoEvents Method – Programming, Pseudocode Example, C# Programming Example
Windows Form

Winforms Application.DoEvents Method

Application.DoEvents Method Processes all Windows messages currently in the message queue.

To understand how Application.DoEvents() method works, create a new winforms application and add a picturebox and assign a image and add a button to the form.

write the below code, in form1.cs file  Form1_Load method and  button1_Click method

Now run the above code. 

When you click on button, you cannot see the picture box, though we are making picture box visible on button click.

Now uncomment the Applicaton.DoEvents line and run the code. You can see the picture box is visible  on button click because calling  Appliation.DoEvents method makes the current thread to be suspended all the waiting windows messages in the queue to be processed.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.