How could I invoke so I won't get the following error?
System.InvalidOperationException:
The calling thread cannot access this object because a different thread owns it.
// Method 1
if (((SolidColorBrush)RRefresh.Fill).Color == CustomGreen.Color && Foldername == string.Empty)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Driver.Navigate().Refresh();
}));
}
// Method 2
if (Driver != null && ((SolidColorBrush)RRefresh.Fill).Color == CustomGreen.Color)
{
Application.Current.Dispatcher.BeginInvoke(new Action(() =>
{
Driver.Navigate().Refresh();
}));
}