Thread thread = new Thread(new ThreadStart(() =>
{
VisualTarget visualTarget = new VisualTarget(hostVisual);
var control = new UserControl1();
control.Arrange(new Rect(new Point(), content.RenderSize));
visualTarget.RootVisual = control;
System.Windows.Threading.Dispatcher.Run();
}));
thread.SetApartmentState(ApartmentState.STA);
thread.IsBackground = true;
thread.Start();
//同步步执行
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
//操作界面控件
});
beginInvoke //异步执行
System.Windows.Application.Current.Dispatcher.Invoke(() =>
{
//操作界面控件
});
//异步执行
//var sendtask = Task.Factory.StartNew(() =>
//{
//});