在项目里面用了MEF插件框架,在合并部件的时候有点慢想改成用BackgroundWorker加载,调试的时候出错:"调用线程必须为 STA,因为许多 UI 组件都需
要",因为我的每个插件DLL都包含一个UI,所以会造成这样,有没有什么方法可以实现异步合并部件.
谢谢
你好,
据我所知这样是不可以的。在BackgroundWorker中,对UI的操作还是必须要放在UI线程中进行。
建议你在STA线程中创建UI控件,并在需要的时候通过Dispatcher.Invoke在BackgroundWorker中对控件进行操作。
Min Zhu MSDN Community Support | Feedback to us Develop and promote your apps in Windows Store Please remember to mark the replies as answers if they help and unmark them if they provide no help.