Skip to content

Latest commit

 

History

History
59 lines (45 loc) · 1.66 KB

obtaining_the_IThreadHandling_service.md

File metadata and controls

59 lines (45 loc) · 1.66 KB

Obtaining the IProjectThreadingService/IThreadHandling service

Visual Studio 2017: IProjectThreadingService

Visual Studio 2015: IThreadHandling

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).

Visual Studio 2017:

    [Import]
    IProjectThreadingService ProjectThreadingService { get; set; }

Visual Studio 2015:

    [Import]
    IThreadHandling ThreadHandling { get; set; }

From MEF via an imperative GetService query

Visual Studio 2017:

    IProjectService projectService;
    IProjectThreadingService projectThreadingService = projectService.Services.ThreadingPolicy;

Visual Studio 2015:

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

Where projectService is obtained as described in Obtaining the ProjectService.

From a loaded project

Visual Studio 2017:

    IVsBrowseObjectContext context;
    IProjectThreadingService projectThreadingService = context.UnconfiguredProject.ProjectService.Services.ThreadingPolicy;

Visual Studio 2015:

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

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