What is equivalent to Application.DoEvents() in WPF applications

Shamim Hafiz picture Shamim Hafiz · Jul 21, 2011 · Viewed 27.2k times · Source

From MSDN, it seems that Application.DoEvents() is available in Windows.Forms. What would be the equivalent thing in WPF.

Answer

Jon Skeet picture Jon Skeet · Jul 21, 2011

You shouldn't be using it even in Windows Forms. Don't perform long-running tasks on the UI thread - use a background thread and use the Dispatcher to update the UI as required. Any use of Application.DoEvents is basically a code smell. I don't know whether there is an equivalent in WPF, but you should try to avoid it even if there is.