【发布时间】:2018-11-07 17:14:21
【问题描述】:
我怎样才能调用,所以我不会得到以下错误?
System.InvalidOperationException:
调用线程无法访问此对象,因为其他线程拥有它。
// 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();
}));
}
【问题讨论】:
-
将其包装在 Application.Dispatcher.BeginInvoke 方法中。
标签: c#