@@ -30,7 +30,7 @@ namespace GraphicalDebugging
3030 /// To get loaded into VS, the package must be referred by <Asset Type="Microsoft.VisualStudio.VsPackage" ...> in .vsixmanifest file.
3131 /// </para>
3232 /// </remarks>
33- [ PackageRegistration ( UseManagedResourcesOnly = true ) ]
33+ [ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
3434 [ InstalledProductRegistration ( "#110" , "#112" , "1.0" , IconResourceID = 400 ) ] // Info on this package for Help/About
3535 [ ProvideMenuResource ( "Menus.ctmenu" , 1 ) ]
3636 [ Guid ( GraphicalDebuggingPackage . PackageGuidString ) ]
@@ -42,7 +42,7 @@ namespace GraphicalDebugging
4242 [ ProvideOptionPage ( typeof ( GeometryWatchOptionPage ) , "Graphical Debugging" , "Geometry Watch" , 0 , 0 , true ) ]
4343 [ ProvideOptionPage ( typeof ( GraphicalWatchOptionPage ) , "Graphical Debugging" , "Graphical Watch" , 0 , 0 , true ) ]
4444 [ ProvideOptionPage ( typeof ( PlotWatchOptionPage ) , "Graphical Debugging" , "Plot Watch" , 0 , 0 , true ) ]
45- public sealed class GraphicalDebuggingPackage : Package
45+ public sealed class GraphicalDebuggingPackage : AsyncPackage
4646 {
4747 /// <summary>
4848 /// GraphicalDebuggingPackage GUID string.
@@ -71,22 +71,19 @@ public GraphicalDebuggingPackage()
7171 /// Initialization of the package; this method is called right after the package is sited, so this is the place
7272 /// where you can put all the initialization code that rely on services provided by VisualStudio.
7373 /// </summary>
74- protected override void Initialize ( )
74+ protected override async Task InitializeAsync ( CancellationToken cancellationToken , IProgress < ServiceProgressData > progress )
7575 {
76- Instance = this ;
76+ // When initialized asynchronously, the current thread may be a background thread at this point.
77+ // Do any initialization that requires the UI thread after switching to the UI thread.
78+ await this . JoinableTaskFactory . SwitchToMainThreadAsync ( cancellationToken ) ;
7779
78- base . Initialize ( ) ;
80+ Instance = this ;
7981
80- ExpressionLoader . Initialize ( this ) ;
82+ await ExpressionLoader . InitializeAsync ( this ) ;
8183
82- GeometryWatchCommand . Initialize ( this ) ;
83- GraphicalWatchCommand . Initialize ( this ) ;
84- PlotWatchCommand . Initialize ( this ) ;
85- }
86-
87- public new object GetService ( Type serviceType )
88- {
89- return base . GetService ( serviceType ) ;
84+ await GeometryWatchCommand . InitializeAsync ( this ) ;
85+ await GraphicalWatchCommand . InitializeAsync ( this ) ;
86+ await PlotWatchCommand . InitializeAsync ( this ) ;
9087 }
9188
9289 public new DialogPage GetDialogPage ( Type dialogPageType )
0 commit comments