标签搜索
C#

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

Y
Y
2020-05-19 / 0 评论 / 84 阅读 / 正在检测是否收录...
温馨提示:
本文最后更新于2020年05月19日,已超过1221天没有更新,若内容或图片失效,请留言反馈。

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

评论 (0)

取消