-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Make InlineReviewsPackage async. #1497
Changes from 2 commits
01bbc84
26186b9
9548228
4c36404
6319d28
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,24 +1,32 @@ | ||
| using System; | ||
| using System.ComponentModel.Design; | ||
| using System.Runtime.InteropServices; | ||
| using System.Threading; | ||
| using GitHub.InlineReviews.Commands; | ||
| using GitHub.InlineReviews.Views; | ||
| using GitHub.VisualStudio; | ||
| using Microsoft.VisualStudio.ComponentModelHost; | ||
| using Microsoft.VisualStudio.Shell; | ||
| using Microsoft.VisualStudio.Shell.Interop; | ||
| using Task = System.Threading.Tasks.Task; | ||
|
|
||
| namespace GitHub.InlineReviews | ||
| { | ||
| [PackageRegistration(UseManagedResourcesOnly = true)] | ||
| [PackageRegistration(UseManagedResourcesOnly = true, AllowsBackgroundLoading = true)] | ||
| [Guid(Guids.InlineReviewsPackageId)] | ||
| [ProvideAutoLoad(UIContextGuids80.SolutionExists)] | ||
| [ProvideMenuResource("Menus.ctmenu", 1)] | ||
| [ProvideToolWindow(typeof(PullRequestCommentsPane), DocumentLikeTool=true)] | ||
| public class InlineReviewsPackage : Package | ||
| public class InlineReviewsPackage : AsyncPackage | ||
| { | ||
| protected override void Initialize() | ||
| protected override async Task InitializeAsync( | ||
| CancellationToken cancellationToken, | ||
| IProgress<ServiceProgressData> progress) | ||
| { | ||
| base.Initialize(); | ||
| PackageResources.Register(this); | ||
| await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); | ||
| var menuService = (IMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService))); | ||
| var componentModel = (IComponentModel)(await GetServiceAsync(typeof(SComponentModel))); | ||
| PackageResources.Register(this, componentModel.DefaultExportProvider, menuService); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It would be better to go through Going through
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with |
||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This will cause the package to auto-load on the Main thread. I think we should be using this:
In future we might want to only auto-load when there is an active Git repository (see #1512)?