diff --git a/Codist/Helpers/ServicesHelper.cs b/Codist/Helpers/ServicesHelper.cs index 6ebd3f02..8dbd6fa8 100644 --- a/Codist/Helpers/ServicesHelper.cs +++ b/Codist/Helpers/ServicesHelper.cs @@ -78,7 +78,6 @@ private ServicesHelper() { internal SyntaxHighlight.ClassificationTypeExporter ClassificationTypeExporter { get; } public static TInterface Get() where TInterface : class { - ThreadHelper.ThrowIfNotOnUIThread(); return ServiceProvider.GlobalProvider.GetService(typeof(VSInterface)) as TInterface; } diff --git a/Codist/Helpers/ThemeHelper.cs b/Codist/Helpers/ThemeHelper.cs index 06699379..d7b1783f 100644 --- a/Codist/Helpers/ThemeHelper.cs +++ b/Codist/Helpers/ThemeHelper.cs @@ -65,7 +65,6 @@ static ThemeHelper() { #region Theme events static KeyValuePair GetCurrentThemeInfo() { - ThreadHelper.ThrowIfNotOnUIThread(); var i = ServicesHelper.Get(); if (i == null) { "Failed to cast IVsColorThemeService.".Log(); @@ -79,7 +78,6 @@ static KeyValuePair GetCurrentThemeInfo() { // in VS 2022, SVsColorThemeService somehow can't be cast to IVsColorThemeService, // we have to use dynamic in this case static KeyValuePair CompatibleGetThemeInfo() { - ThreadHelper.ThrowIfNotOnUIThread(); dynamic s = ServiceProvider.GlobalProvider.GetService(new Guid("0D915B59-2ED7-472A-9DE8-9161737EA1C5")); if (s == null) { return new KeyValuePair(Guid.Empty, String.Empty); diff --git a/Codist/QuickInfo/QuickInfoFactories.cs b/Codist/QuickInfo/QuickInfoFactories.cs index c7d8eb9a..cd13b9e7 100644 --- a/Codist/QuickInfo/QuickInfoFactories.cs +++ b/Codist/QuickInfo/QuickInfoFactories.cs @@ -127,7 +127,18 @@ Task IAsyncQuickInfoSource.GetQuickInfoItemAsync(IAsyncQuickInfoS protected abstract Task GetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken); async Task InternalGetQuickInfoItemAsync(IAsyncQuickInfoSession session, CancellationToken cancellationToken) { - var item = await GetQuickInfoItemAsync(session, cancellationToken).ConfigureAwait(false); + QuickInfoItem item; + await SyncHelper.SwitchToMainThreadAsync(cancellationToken); + try { + item = await GetQuickInfoItemAsync(session, cancellationToken); + } + catch (OperationCanceledException) { + throw; + } + catch (Exception ex) { + Controls.MessageWindow.Error(ex, null, Properties.Resources.T_SuperQuickInfo, this); + return null; + } if (item != null) { session.Properties.AddProperty(GetType(), this); }