When you run a Windows Form, it creates the new form, which then waits for
events to handle. Each time the form handles an event, it processes all the
code associated with that event. All other events wait in the queue. While your
code handles the event, your application does not respond. For example, the
window does not repaint if another window is dragged on top.

If you call DoEventsin your code, your
application can handle the other events. For example, if you have a form that
adds data to a ListBox
and add DoEventsto your code, your form repaints
when another window is dragged over it. If you remove DoEventsfrom your code, your form will not repaint until the click event handler of the
button is finished executing.

Caution

Calling this method causes the
current thread to be suspended while all waiting window messages are processed.
If a message causes an event to be triggered, then other areas of your
application code may execute. This can cause your application to exhibit unexpected
behaviors that are difficult to debug. If you perform operations or
computations that take a long time, it is often preferable to perform those
operations on a new thread. For more information about asynchronous
programming,

Promote Us

Be a part of our site promotion through making small contribution to our future development in website,Only with your help we can maintain these sites. In future we will launch many useful programming sites.