11using System . Runtime . InteropServices ;
22using System . Threading ;
3+ using System . Windows ;
34
45using ChinesePinyinIntelliSenseExtender . Options ;
56using ChinesePinyinIntelliSenseExtender . Util ;
1213namespace ChinesePinyinIntelliSenseExtender ;
1314
1415[ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
15- [ Guid ( ChinesePinyinIntelliSenseExtenderPackage . PackageGuidString ) ]
16- [ ProvideOptionPage ( typeof ( OptionPages . General ) , "IntelliSense拼音补全" , "常规" , 0 , 0 , true ) ]
17- [ ProvideOptionPage ( typeof ( OptionPages . DictionaryManage ) , "IntelliSense拼音补全" , "字典" , 0 , 0 , true ) ]
16+ [ Guid ( PackageGuidString ) ]
17+ [ ProvideOptionPage ( typeof ( OptionPages . General ) , PackageName , "常规" , 0 , 0 , true ) ]
18+ [ ProvideOptionPage ( typeof ( OptionPages . DictionaryManage ) , PackageName , "字典" , 0 , 0 , true ) ]
1819[ ProvideAutoLoad ( UIContextGuids80 . NoSolution , PackageAutoLoadFlags . BackgroundLoad ) ]
1920[ ProvideAutoLoad ( UIContextGuids80 . SolutionExists , PackageAutoLoadFlags . BackgroundLoad ) ]
2021[ ProvideAutoLoad ( UIContextGuids80 . SolutionHasMultipleProjects , PackageAutoLoadFlags . BackgroundLoad ) ]
@@ -28,6 +29,8 @@ public sealed class ChinesePinyinIntelliSenseExtenderPackage : AsyncPackage
2829 /// </summary>
2930 public const string PackageGuidString = "cd4393db-d533-4077-93da-9fdad98ddacf" ;
3031
32+ public const string PackageName = "IntelliSense拼音补全" ;
33+
3134 #endregion Public 字段
3235
3336 #region Package Members
@@ -38,8 +41,16 @@ protected override async Task InitializeAsync(CancellationToken cancellationToke
3841
3942 var options = await DictionaryManageOptions . GetLiveInstanceAsync ( cancellationToken ) ;
4043
41- _ = InputMethodDictionaryGroupProvider . LoadFromOptionsAsync ( options , cancellationToken ) ;
44+ _ = InputMethodDictionaryGroupProvider . LoadFromOptionsAsync ( options , cancellationToken ) . ContinueWith ( task =>
45+ {
46+ if ( task . Exception is not null )
47+ {
48+ var exception = task . Exception . InnerException ? . ToString ( ) ;
49+ cancellationToken . ThrowIfCancellationRequested ( ) ;
50+ MessageBox . Show ( $ "Load options failed with \" { exception } \" ", PackageName , MessageBoxButton . OK , MessageBoxImage . Error ) ;
51+ }
52+ } , cancellationToken , TaskContinuationOptions . OnlyOnFaulted , TaskScheduler . Current ) ;
4253 }
4354
4455 #endregion Package Members
45- }
56+ }
0 commit comments