wpf 线程与界面线程

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(() =>
//{

//});

上一篇:Monkey测试2——Monkey测试策略


下一篇:Visual Studio Code 配置Go 开发环境最简单的方法!!!