I expect your code isn't compiling. You should change your dispatcher todo this:
Dispatcher.Invoke( new Action( () =>
{
lab1.Visibility = Visibility.Visible;
lab2.Visibility = Visibility.Hidden;
lab3.Visibility = Visibility.Hidden;
} ) );
The Dispatcher
is used to dispatch items from different threads onto the UI thread. CheckAccess()
will check to see if you are on the Dispatcher
thread (or UI thread). If you already are, it will not go into your if statement. Are you absolutely sure that you already aren't on the Dispatcher
thread?