The calling thread must be STA, because many UI components require this.
在WPF项目中,在线程中操作UI,报出以下错误:
The calling thread must be STA, because many UI components require this.
本文记录解决方案
MvvmLightLibs
首先想到借助MvvmLightLibs类库的DispatcherHelper.RunAsync(Action action)方法, 虽然不再报错了,但是UI界面也并未更新,于是进一步探索。
Application.Current.Dispatcher.Invoke
又尝试解决方案如下:
搞定