Below is the short example for my question. At the beginning of the function I would like to change some visual paramater, such hide window, make it red ("my example") and at the end of the function, I would like to put it back. Somethig like mouse wait cursor for long-term function.
Is there any elegant way to make the button red before function OnButtonClick ends - way to allow window message loop to process request Background=Red in parallel way and immediately redraw window.
private void OnButtonClick(object sender, RoutedEventArgs e)
{
System.Windows.Media.Brush br = ((Button)sender).Background;
((Button)sender).Background = System.Windows.Media.Brushes.Red;
Mouse.OverrideCursor = Cursors.Wait;
Function(); //long-term function
Mouse.OverrideCursor = Cursors.Arrow;
((Button)sender).Background = br;
}