This repository was archived by the owner on Jun 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Create and add MEF commands on background thread #1548
Closed
Closed
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
c20e618
Create MEF commands on background thread
jcansdale 0527497
Allow menuService.AddCommands to be called from a b/g thread
jcansdale 266ec58
Construct PullRequestStatusBarManager using MEF on b/g thread
jcansdale 5730008
Factor b/g loading menu code into AsyncMenuPackage
jcansdale ec46954
Restore missing metrics
jcansdale File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
using System; | ||
using System.Threading; | ||
using System.ComponentModel.Design; | ||
using Microsoft.VisualStudio.Shell; | ||
using Microsoft.VisualStudio.Shell.Interop; | ||
using Task = System.Threading.Tasks.Task; | ||
|
||
namespace GitHub.Services.Vssdk | ||
{ | ||
public abstract class AsyncMenuPackage : AsyncPackage | ||
{ | ||
IVsUIShell vsUIShell; | ||
|
||
sealed protected async override Task InitializeAsync(CancellationToken cancellationToken, IProgress<ServiceProgressData> progress) | ||
{ | ||
vsUIShell = await GetServiceAsync(typeof(SVsUIShell)) as IVsUIShell; | ||
|
||
var menuCommandService = (OleMenuCommandService)(await GetServiceAsync(typeof(IMenuCommandService))); | ||
await InitializeMenusAsync(menuCommandService); | ||
} | ||
|
||
protected abstract Task InitializeMenusAsync(OleMenuCommandService menuService); | ||
|
||
// The IDesignerHost, ISelectionService and IVsUIShell are requested by the MenuCommandService. | ||
// This override allows IMenuCommandService.AddCommands to be called form a background thread. | ||
protected override object GetService(Type serviceType) | ||
{ | ||
if (serviceType == typeof(SVsUIShell)) | ||
{ | ||
return vsUIShell; | ||
} | ||
|
||
if (serviceType == typeof(ISelectionService) || serviceType == typeof(IDesignerHost)) | ||
{ | ||
return null; | ||
} | ||
|
||
return base.GetService(serviceType); | ||
} | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Needs some (preferably gramatical) xmldoc comments. 😉