I click the button background of border is blue, after one second it should be red. It is red but not blue. Why?
<Window x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Border Width="111" Name="op" Height="111">
<Button Name="opbtn" Click="opbtn_Click" Width="50" Height="23">click</Button>
</Border>
</Window>
Code-behind:
private void opbtn_Click(object sender, RoutedEventArgs e)
{
op.BorderBrush = System.Windows.Media.Brushes.Blue;
DateTime obj1 = new DateTime();
DateTime obj2 = DateTime.Now.AddMilliseconds(200);
while (obj2 > obj1)
{
obj1 = DateTime.Now;
}
op.BorderBrush = System.Windows.Media.Brushes.Red;
}