I have a custom WPF control that I want to show when a button is clicked and hide when processing is finished, I am trying this but the control is not visible until the processing is done.
public delegate void UpdateTextCallback(string message);
private void UpdateText(string message)
{
if (message == "v")
crclLoading.Visibility = Visibility.Visible;
else
crclLoading.Visibility = Visibility.Hidden;
}
private void TestThread()
{
crclLoading.Dispatcher.Invoke(
new UpdateTextCallback(this.UpdateText),
new object[] {"v" }
);
}
private void TestThread2()
{
crclLoading.Dispatcher.Invoke(
new UpdateTextCallback(this.UpdateText),
new object[] { "s" }
);
}
and in butoon_click:
Thread show= new Thread(new ThreadStart(TestThread));
show.Start();
//long time conusming processing
Thread hide= new Thread(new ThreadStart(TestThread2));
hide.Start();