Skip to content

Instantly share code, notes, and snippets.

@M-Yankov
Created September 24, 2016 22:03
Show Gist options
  • Save M-Yankov/503ea12248cbfb99c52327130aae84c4 to your computer and use it in GitHub Desktop.
Save M-Yankov/503ea12248cbfb99c52327130aae84c4 to your computer and use it in GitHub Desktop.
WPF refresh UI
public static class ExtensionMethods
{
private static Action EmptyDelegate = delegate() { };
public static void Refresh(this UIElement uiElement)
{
uiElement.Dispatcher.Invoke(DispatcherPriority.Render, EmptyDelegate);
}
}
private void LoopingMethod()
{
for (int i = 0; i < 10; i++)
{
label1.Content = i.ToString();
label1.Refresh();
Thread.Sleep(500);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment