VSTO Outlook加载项,是否需要从主线程完成UI操作? [英] VSTO Outlook add-in, does UI manipulation need to be done from main thread?
问题描述
我正在维护Outlook的VSTO加载项,它具有处理与服务器同步的BackgroundWorker.我希望工作人员在用户界面中触发用户错误(更改按钮上的图片,在设置窗口中启用消息).
是否需要在初始线程中进行UI操作?
此StackOverflow答案不会,但是解决方案
是的,所有Outlook/Office对象模型访问都必须从主线程完成.参见带有Windows窗体和工作线程的VSTO >
I'm maintaining a VSTO add-in for Outlook, and it has a BackgroundWorker that handles syncing with a server. I want the worker to trigger user errors in the UI (changing the picture on a button, enabling a message in a settings window).
Does UI manipulation need to be done from the initial thread?
This StackOverflow answer says not, but a comment on it says so. It's for Excel, but still for a VSTO add-in. I tried and it seems to work from either thread, but there could be a race condition I haven't hit yet.
Yes, all Outlook / Office Object Model access must be done from the main thread. See VSTO with Windows Form and Worker Threads
这篇关于VSTO Outlook加载项,是否需要从主线程完成UI操作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!