If you are performing an extensive operation that has multiple UI updates, for example in a loop, then you can use the following code to keep the UI updated alongside the operation.
Simply call that function inside your loop and the UI will update. Note, I have set the priority to background, you may have to set that to "Render"
1 2 3 4 5 6 7 8 9 10 | private void UpdateUI() { DispatcherFrame update = new DispatcherFrame(); Dispatcher.CurrentDispatcher.BeginInvoke(DispatcherPriority.Background, new DispatcherOperationCallback(delegate (object parameter) { update.Continue = false; return null; }), null); Dispatcher.PushFrame(update); } |
Simply call that function inside your loop and the UI will update. Note, I have set the priority to background, you may have to set that to "Render"
Comments
Post a Comment