public async Task <IEnumerable <VsExpansion> > GetAvailableSnippetsAsync() { if (_expansionMgr == null) { return(Enumerable.Empty <VsExpansion>()); } try { var enumerator = await _expansionMgr.EnumerateExpansionsAsync(CommonGuidList.guidPythonLanguageServiceGuid, 1, null, 0, 0, 0); if (enumerator == null) { return(null); } var res = new List <VsExpansion>(); foreach (var e in COMEnumerable.ToList <VsExpansion>(enumerator.Next)) { res.Add(e); } return(res); } catch (Exception ex) { Debug.Fail(ex.ToUnhandledExceptionMessage(GetType())); return(Enumerable.Empty <VsExpansion>()); } }
private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager) { AssertIsBackground(); var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync( _languageGuidForSnippets, 0, // shortCutOnly Array.Empty <string>(), // types 0, // countTypes 1, // includeNULLTypes 1 // includeDulicates: Allows snippets with the same title but different shortcuts ).ConfigureAwait(false); // The rest of the process requires being on the UI thread, see the explanation on // PopulateSnippetCacheFromExpansionEnumeration for details await ThreadingContext.JoinableTaskFactory.SwitchToMainThreadAsync(); PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator); }
private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager) { AssertIsBackground(); var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync( _languageGuidForSnippets, 0, // shortCutOnly Array.Empty <string>(), // types 0, // countTypes 1, // includeNULLTypes 1 // includeDulicates: Allows snippets with the same title but different shortcuts ).ConfigureAwait(false); // The rest of the process requires being on the UI thread, see the explanation on // PopulateSnippetCacheFromExpansionEnumeration for details await Task.Factory.StartNew(() => PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator), CancellationToken.None, TaskCreationOptions.None, ForegroundTaskScheduler).ConfigureAwait(false); }
private async Task PopulateSnippetCacheAsync(IExpansionManager expansionManager) { AssertIsBackground(); var expansionEnumerator = await expansionManager.EnumerateExpansionsAsync( _languageGuidForSnippets, 0, // shortCutOnly Array.Empty<string>(), // types 0, // countTypes 1, // includeNULLTypes 1 // includeDulicates: Allows snippets with the same title but different shortcuts ).ConfigureAwait(false); // The rest of the process requires being on the UI thread, see the explanation on // PopulateSnippetCacheFromExpansionEnumeration for details await Task.Factory.StartNew(() => PopulateSnippetCacheFromExpansionEnumeration(expansionEnumerator), CancellationToken.None, TaskCreationOptions.None, ForegroundTaskScheduler).ConfigureAwait(false); }