What exactly does the Application.DoEvents () method do?

3

According to Microsoft help , the Application.DoEvents () :

  

Process all Windows messages that are currently in the message queue.

But what does that mean?

Why does he say messages? What line is this?

    
asked by anonymous 02.10.2017 / 20:08

1 answer

3

Message is a term that Windows uses. When you program for Windows you're using a framework of it, then the application all the time communicating with the operating system through messaging. It is easy to send messages to him when he wants, but to receive he needs to sign up for the pool event and he will call his role whenever he has a message to his application. It's like the C # event system, but in a slightly lower level way, basically a callback function and a huge switch to decide what to do according to the message received. p>

This method reads these messages. I'm not sure, but it's possible that it does with internal Windows Forms messages that are not coming from Windows. This may be necessary to "unlock" the loop of events in applications with a single thread . Its use simplifies the application by maintaining a certain responsiveness (in the correct sense of the word, not how to use it on the web) of the UI.

In most applications its use is not necessary and today when it has something that can handle the execution it is recommended to use asynchronicity . If you do not know how to use it right, and it's difficult, you can create complications for the application . There was a time that was more useful for lack of a better option, so many old articles on the subject may have their expiry date expired.

    
02.10.2017 / 20:36