I want to disable a button as soon as a user clicks it to stop them clicking it again. There are a number of checks that are performed when they click it, and it appears these checks are done before the UI change takes place.
I am trying to do this by using a separate thread for the button, but it still seems to only update after the checks are done.
Here's the code I am using:
private void Button_Click(object sender, RoutedEventArgs e)
{
Thread t = new Thread(new ThreadStart(
delegate
{
Action action = () => btnStart.IsEnabled = false;
Dispatcher.BeginInvoke(action);
}
));
t.Start();
// Run the main routine;
BeginBootstrapping();
}
How can I disable the button straight away?