1
1
using System ;
2
2
using System . Diagnostics . CodeAnalysis ;
3
3
using System . Runtime . InteropServices ;
4
+ using System . Threading ;
5
+ using System . Threading . Tasks ;
4
6
using System . Windows . Threading ;
5
7
using EnvDTE ;
6
8
using EnvDTE80 ;
12
14
13
15
namespace WebCompilerVsix
14
16
{
15
- [ PackageRegistration ( UseManagedResourcesOnly = true ) ]
17
+ [ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
16
18
[ InstalledProductRegistration ( "#110" , "#112" , Version , IconResourceID = 400 ) ]
17
19
[ ProvideMenuResource ( "Menus.ctmenu" , 1 ) ]
18
20
[ Guid ( PackageGuids . guidCompilerPackageString ) ]
19
- [ ProvideAutoLoad ( UIContextGuids80 . SolutionExists ) ]
20
- public sealed class WebCompilerPackage : Package
21
+ [ ProvideAutoLoad ( UIContextGuids80 . SolutionExists , PackageAutoLoadFlags . BackgroundLoad ) ]
22
+ public sealed class WebCompilerPackage : AsyncPackage
21
23
{
22
24
public const string Version = "1.4.167" ;
23
25
public static DTE2 _dte ;
24
26
public static Package Package ;
25
27
private SolutionEvents _solutionEvents ;
26
28
private BuildEvents _buildEvents ;
27
29
28
- protected override void Initialize ( )
30
+ protected override async System . Threading . Tasks . Task InitializeAsync ( CancellationToken cancellationToken , IProgress < ServiceProgressData > progress )
29
31
{
32
+ await ThreadHelper . JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
33
+
30
34
_dte = GetService ( typeof ( DTE ) ) as DTE2 ;
31
35
Package = this ;
32
36
@@ -46,8 +50,6 @@ protected override void Initialize()
46
50
RemoveConfig . Initialize ( this ) ;
47
51
CompileAllFiles . Initialize ( this ) ;
48
52
CleanOutputFiles . Initialize ( this ) ;
49
-
50
- base . Initialize ( ) ;
51
53
}
52
54
53
55
private void OnBuildBegin ( vsBuildScope Scope , vsBuildAction Action )
@@ -74,15 +76,18 @@ public static bool IsDocumentDirty(string documentPath, out IVsPersistDocData pe
74
76
}
75
77
}
76
78
77
- [ ProvideAutoLoad ( UIContextGuids80 . SolutionExists ) ]
78
- [ ProvideAutoLoad ( UIContextGuids80 . NoSolution ) ]
79
- public sealed class WebCompilerInitPackage : Package
79
+ [ PackageRegistration ( UseManagedResourcesOnly = true , AllowsBackgroundLoading = true ) ]
80
+ [ ProvideAutoLoad ( UIContextGuids80 . SolutionExists , PackageAutoLoadFlags . BackgroundLoad ) ]
81
+ [ ProvideAutoLoad ( UIContextGuids80 . NoSolution , PackageAutoLoadFlags . BackgroundLoad ) ]
82
+ public sealed class WebCompilerInitPackage : AsyncPackage
80
83
{
81
84
public static Dispatcher _dispatcher ;
82
85
public static DTE2 _dte ;
83
86
84
- protected override void Initialize ( )
87
+ protected override async System . Threading . Tasks . Task InitializeAsync ( CancellationToken cancellationToken , IProgress < ServiceProgressData > progress )
85
88
{
89
+ await JoinableTaskFactory . SwitchToMainThreadAsync ( ) ;
90
+
86
91
_dispatcher = Dispatcher . CurrentDispatcher ;
87
92
_dte = GetService ( typeof ( DTE ) ) as DTE2 ;
88
93
0 commit comments