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);
});
});
这篇博客探讨了如何在WPF应用中使用匿名线程和指定函数启动线程,以及如何在非UI线程中安全地更新用户界面。示例代码展示了如何利用Dispatcher.Invoke方法在后台线程中修改UI元素属性,确保了UI操作的同步性。
220

被折叠的 条评论
为什么被折叠?



