obtaining_the_IThreadHandling_service.md
April 22, 2022 ยท View on GitHub
Obtaining the IProjectThreadingService service
=====================================
From MEF via import
Note that importing any CPS related service moves your MEF part from the
VS default MEF catalog into a CPS catalog "sub-scope". Import properties
are only 'satisfied' when MEF activated your type (not simply by newing
up an instance of your object).
[Import]
IProjectThreadingService ProjectThreadingService { get; set; }
From MEF via an imperative GetService query
IProjectService projectService;
IProjectThreadingService projectThreadingService = projectService.Services.ThreadingPolicy;
Where projectService is obtained as described in
Obtaining the ProjectService.
From a loaded project
IVsBrowseObjectContext context;
IProjectThreadingService projectThreadingService = context.UnconfiguredProject.ProjectService.Services.ThreadingPolicy;
Where context is obtained as described in Finding CPS in a VS
project.