Microsoft recommends a slightly different way of doing what your code does using PushFrame .
The code has nothing to do with rendering. What it does is similar to the DoEvents method known from VB6 and WinForms. DoEvents stops the program while pumping the Windows message queue and processing messages in the queue. This includes any rendering messages such as WM_PAINT and WM_NCPAINT .
The code tells the dispatcher to stop the current thread and pump its queue and process all messages that have DispatcherPriority.Render priority or higher. If there are pending rendering messages in the queue, for example, if InvalidateRect was called somewhere within the framework, these messages will be processed and the user interface will be displayed again.
DoEvents has always been considered a code smell because it bypasses the message queue. If you need a flexible user interface, you should use workflows instead.
source share