Skip to content

Latest commit

 

History

History
34 lines (25 loc) · 1 KB

obtaining_the_IThreadHandling_service.md

File metadata and controls

34 lines (25 loc) · 1 KB

Obtaining the IThreadHandling 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]
    IThreadHandling ThreadHandling { get; set; }

From MEF via an imperative GetService query

    ProjectService projectService;
    IThreadHandling threadHandling = projectService.Services.ThreadingPolicy;

Where projectService is obtained as described in Obtaining the ProjectService.

From a loaded project

    IVsBrowseObjectContext context;
    IThreadHandling threadHandling = context.UnconfiguredProject.ProjectService.Services.ThreadingPolicy;

Where context is obtained as described in Finding CPS in a VS project.