Update WPF UI During Method Execution


Samuel Jack of Seaturtle Software Limited has produced an interesting method that allows you to force the WPF UI to update during a method call. Here is the code:

void AllowUIToUpdate() {
DispatcherFrame frame = new DispatcherFrame();
Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Render, new DispatcherOperationCallback(delegate(object parameter)
{
frame.Continue = false;
return null;
}), null);
Dispatcher.PushFrame(frame);
}

This code help me to fix an issue that I had with my WPF program. The original article is called Forcing Update of UI before my function exits.

Advertisements