DoEvents() in WPF

DoEvents() allows the UI to refresh while your perform a long lasting action, like parsing over a lot of files. In the windows forms you can just call DoEvents() from inside your blocking structure but in WPF this is not available, at least not by default.

To get DoEvents() in WPF we first need to add a reference to Forms to our project. This can be done by doing a right click on our project, then clicking “add reference”. Go to the .NET tab and look for System.Windows.Forms, click on it and then click OK.

Now you can call do Events by Using System.Windows.Forms.Application.DoEvents();.


Posted in

Leave a Reply

Your email address will not be published. Required fields are marked *

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