Thread-safety of Addin construction (parallel loading)
- Last UpdatedOct 28, 2026
- 1 minute read
The Common Application Framework (CAF) loads all addin assemblies and constructs the addin objects in parallel (Parallel.For inside AddinManagerImpl.LoadAddins). Your addin's constructor and any field initializers run on a ThreadPool worker thread, concurrently with the construction of other addins.
Therefore, in a constructor you must not:
-
Create or touch WinForms controls, windows, the ribbon, or any User Interface (UI) object (UI has thread affinity and this will throw or corrupt state on a non-UI thread).
-
Assume any other addin has been constructed or started (there is no ordering between constructors).
-
Mutate a shared or static state without synchronization.
-
Call CAF services that are only valid after start-up has completed.
Keep constructors cheap and self-contained: store the assembly path or config, and set defaults. Defer all real work to Start(), which is always invoked on the UI thread.
Inter-addin communication must go through events or services resolved at Start() time or later, and not through construction-time coupling.