首页 > 代码库 > wpf 线程与界面线程

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

//界面线程不要执行大量操作 否则还是卡顿
});

wpf 线程与界面线程