private void RunJTFWithCorrectContext(Project project, Func <Task> asyncTask)
        {
            if (!_isCPSJTFLoaded)
            {
                NuGetUIThreadHelper.JoinableTaskFactory.Run(async() =>
                {
                    await NuGetUIThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync();

                    var vsHierarchy = VsHierarchyUtility.ToVsHierarchy(project);
                    if (vsHierarchy != null &&
                        VsHierarchyUtility.IsCPSCapabilityComplaint(vsHierarchy))
                    {
                        // Lazy load the CPS enabled JoinableTaskFactory for the UI.
                        NuGetUIThreadHelper.SetJoinableTaskFactoryFromService(ProjectServiceAccessor.Value as IProjectServiceAccessor);

                        PumpingJTF      = new PumpingJTF(NuGetUIThreadHelper.JoinableTaskFactory);
                        _isCPSJTFLoaded = true;
                    }
                });
            }

            PumpingJTF.Run(asyncTask);
        }
Exemplo n.º 2
0
 public static VsHierarchyItem FromDteProject(EnvDTE.Project project)
 {
     ThreadHelper.ThrowIfNotOnUIThread();
     Assumes.Present(project);
     return(new VsHierarchyItem(VsHierarchyUtility.ToVsHierarchy(project)));
 }
Exemplo n.º 3
0
 public static VsHierarchyItem FromDteProject(EnvDTE.Project project)
 {
     Assumes.Present(project);
     return(new VsHierarchyItem(VsHierarchyUtility.ToVsHierarchy(project)));
 }