C#

WPF线程,线程中刷新UI界面

王先生
2020-05-19 / 0 评论 / 7 阅读 / 正在检测是否收录...

WPF匿名线程执行

Thread thread = new Thread(() => { 此处填写代码 });
thread.Start();

WPF线程启动

Thread thread = new Thread( 此处填写要执行的函数 );
thread.Start();

WPF线程中更新UI

this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate { 此处填写代码 });

Demo

Thread thread = new Thread(() => {
                this.Dispatcher.Invoke(DispatcherPriority.Normal, (ThreadStart)delegate {
                    CarInfoViewMode_.CarID = CarID;
                    CarInfoViewMode_.CarProvince = Ytools.proCode2str(province);
                    CarInfoViewMode_.CarArea = SqlHelper.sendSQL(str);
                    CarInfoViewMode_.CarType = Ytools.typeCode2str(size);
                });
            });

评论 (0)

取消