private void WaitForAsync(Func <Task> asyncFunc) => ThreadHandling?.ExecuteSynchronously(asyncFunc);
private T WaitForAsync <T>(Func <Task <T> > asyncFunc) => ThreadHandling != null?ThreadHandling.ExecuteSynchronously <T>(asyncFunc) : default(T);
private void WaitForAsync(Func <Task> asyncFunc) { Debug.Assert(ThreadHandling != null); ThreadHandling.ExecuteSynchronously(asyncFunc); }
public void SetObjects(uint cObjects, object[] ppunk) { // If asked to, release our cached selected Project object(s) UnconfiguredProject = null; ConfiguredProperties = null; if (cObjects == 0) { // If we have never configured anything (maybe a failure occurred // on open so app designer is closing us). In this case do nothing. if (ThreadHandling != null) { SetObjects(true); } return; } if (ppunk.Length < cObjects) { throw new ArgumentOutOfRangeException(nameof(cObjects)); } var configuredProjectsProperties = new List <ProjectProperties>(); // Look for an IVsBrowseObject for (int i = 0; i < cObjects; ++i) { var browseObj = ppunk[i] as IVsBrowseObject; if (browseObj != null) { IVsHierarchy hier = null; uint itemid; int hr; hr = browseObj.GetProjectItem(out hier, out itemid); Debug.Assert(itemid == VSConstants.VSITEMID_ROOT, "Selected object should be project root node"); if (hr == VSConstants.S_OK && itemid == VSConstants.VSITEMID_ROOT) { UnconfiguredProject = hier.GetUnconfiguredProject(); // We need to save ThreadHandling because the app designer will call SetObjects with null, and then call // Deactivate(). We need to run async code during Deactivate() which requires ThreadHandling. ThreadHandling = UnconfiguredProject.Services.ExportProvider.GetExportedValue <IThreadHandling>(); var pcg = ppunk[i] as IVsProjectCfg2; if (pcg != null) { string vsConfigName; pcg.get_CanonicalName(out vsConfigName); ThreadHandling.ExecuteSynchronously(async delegate { var provider = new ConfiguredRProjectExportProvider(); var configuredProjProps = await provider.GetExportAsync <ProjectProperties>(UnconfiguredProject, vsConfigName); configuredProjectsProperties.Add(configuredProjProps); }); } } } ConfiguredProperties = configuredProjectsProperties.ToArray(); } SetObjects(false); }
private T WaitForAsync <T>(Func <Task <T> > asyncFunc) { Debug.Assert(ThreadHandling != null); return(ThreadHandling.ExecuteSynchronously <T>(asyncFunc)); }