|
6 | 6 | using System.ComponentModel.Design;
|
7 | 7 | using System.Linq;
|
8 | 8 | using System.Runtime.InteropServices;
|
| 9 | +using System.Threading; |
| 10 | +using Microsoft.VisualStudio; |
9 | 11 | using Microsoft.VisualStudio.ComponentModelHost;
|
10 | 12 | using Microsoft.VisualStudio.OLE.Interop;
|
11 | 13 | using Microsoft.VisualStudio.Shell;
|
|
19 | 21 | using IServiceProvider = System.IServiceProvider;
|
20 | 22 |
|
21 | 23 | namespace VsChromium {
|
22 |
| - [PackageRegistration(UseManagedResourcesOnly = true)] |
| 24 | + [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] |
23 | 25 | [InstalledProductRegistration("#110", "#112", VsChromium.Core.VsChromiumVersion.Product, IconResourceID = 400)]
|
24 | 26 | // When in development mode, update the version # below every time there is a change to the .VSCT file,
|
25 | 27 | // or Visual Studio won't take into account the changes (this is true with VS 2010, maybe not with
|
@@ -61,9 +63,9 @@ namespace VsChromium {
|
61 | 63 | new[] { "VS Chromium", "Chrome", "Coding Style", "Style" },
|
62 | 64 | SupportsProfiles = true)
|
63 | 65 | ]
|
64 |
| - [ProvideAutoLoad(UIContextGuids80.EmptySolution)] |
65 |
| - [ProvideAutoLoad(UIContextGuids80.SolutionExists)] |
66 |
| - public sealed class VsPackage : Microsoft.VisualStudio.Shell.Package, IVisualStudioPackage, IOleCommandTarget { |
| 66 | + [ProvideAutoLoad(VSConstants.UICONTEXT.EmptySolution_string, PackageAutoLoadFlags.BackgroundLoad)] |
| 67 | + [ProvideAutoLoad(VSConstants.UICONTEXT.SolutionExists_string, PackageAutoLoadFlags.BackgroundLoad)] |
| 68 | + public sealed class VsPackage : AsyncPackage, IVisualStudioPackage, IOleCommandTarget { |
67 | 69 | private readonly IDisposeContainer _disposeContainer = new DisposeContainer();
|
68 | 70 |
|
69 | 71 | public VsPackage() {
|
@@ -157,10 +159,16 @@ protected override void Dispose(bool disposing) {
|
157 | 159 | base.Dispose(disposing);
|
158 | 160 | }
|
159 | 161 |
|
160 |
| - protected override void Initialize() { |
| 162 | + protected override async System.Threading.Tasks.Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) { |
| 163 | + // Switches to the UI thread in order to consume some services used in command initialization |
| 164 | + await JoinableTaskFactory.SwitchToMainThreadAsync(cancellationToken); |
| 165 | + |
| 166 | + InitializeUIThread(); |
| 167 | + } |
| 168 | + |
| 169 | + private void InitializeUIThread() { |
161 | 170 | Logger.LogInfo("{0}.Initialize()", this.GetType().FullName);
|
162 | 171 |
|
163 |
| - base.Initialize(); |
164 | 172 | try {
|
165 | 173 | PreInitialize();
|
166 | 174 | PostInitialize();
|
|
0 commit comments