-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathShowToolWindow.cs
More file actions
32 lines (29 loc) · 1.07 KB
/
ShowToolWindow.cs
File metadata and controls
32 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.ComponentModel.Design;
using AsyncToolWindowSample.ToolWindows;
using Microsoft.VisualStudio.Shell;
using Task = System.Threading.Tasks.Task;
namespace AsyncToolWindowSample
{
internal sealed class ShowToolWindow
{
public static async Task InitializeAsync(AsyncPackage package)
{
var commandService = (IMenuCommandService)await package.GetServiceAsync(typeof(IMenuCommandService));
var cmdId = new CommandID(Guid.Parse("9cc1062b-4c82-46d2-adcb-f5c17d55fb85"), 0x0100);
var cmd = new MenuCommand((s, e) => Execute(package), cmdId);
commandService.AddCommand(cmd);
}
private static void Execute(AsyncPackage package)
{
package.JoinableTaskFactory.RunAsync(async () =>
{
ToolWindowPane window = await package.ShowToolWindowAsync(
typeof(SampleToolWindow),
0,
create: true,
cancellationToken: package.DisposalToken);
});
}
}
}