Search code examples
multithreadingoutlookms-officevstoadd-in

VSTO Outlook add-in, does UI manipulation need to be done from main thread?


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.


Solution

  • Yes, all Outlook / Office Object Model access must be done from the main thread. See VSTO with Windows Form and Worker Threads