|
1 | 1 | using System; |
2 | 2 | using System.ComponentModel.Design; |
3 | 3 | using Microsoft.VisualStudio.Shell; |
| 4 | +using System.Threading.Tasks; |
4 | 5 | using Task = System.Threading.Tasks.Task; |
5 | 6 |
|
6 | 7 | namespace FineCodeCoverage.Output |
@@ -82,39 +83,29 @@ public static async Task InitializeAsync(AsyncPackage package) |
82 | 83 | /// <param name="e">The event args.</param> |
83 | 84 | public void Execute(object sender, EventArgs e) |
84 | 85 | { |
85 | | - ShowToolWindow(); |
| 86 | + _ = ThreadHelper.JoinableTaskFactory.RunAsync(ShowToolWindowAsync); |
86 | 87 | } |
87 | 88 |
|
88 | | - public ToolWindowPane ShowToolWindow() |
| 89 | + public async Task<ToolWindowPane> ShowToolWindowAsync() |
89 | 90 | { |
90 | | - ToolWindowPane window = null; |
| 91 | + ToolWindowPane window = await package.ShowToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken); |
91 | 92 |
|
92 | | - package.JoinableTaskFactory.RunAsync(async delegate |
| 93 | + if ((null == window) || (null == window.Frame)) |
93 | 94 | { |
94 | | - window = await package.ShowToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken); |
95 | | - |
96 | | - if ((null == window) || (null == window.Frame)) |
97 | | - { |
98 | | - throw new NotSupportedException($"Cannot create '{Vsix.Name}' output window"); |
99 | | - } |
100 | | - }); |
| 95 | + throw new NotSupportedException($"Cannot create '{Vsix.Name}' output window"); |
| 96 | + } |
101 | 97 |
|
102 | 98 | return window; |
103 | 99 | } |
104 | 100 |
|
105 | | - public ToolWindowPane FindToolWindow() |
| 101 | + public async Task<ToolWindowPane> FindToolWindowAsync() |
106 | 102 | { |
107 | | - ToolWindowPane window = null; |
| 103 | + ToolWindowPane window = await package.FindToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken); |
108 | 104 |
|
109 | | - package.JoinableTaskFactory.RunAsync(async delegate |
| 105 | + if ((null == window) || (null == window.Frame)) |
110 | 106 | { |
111 | | - window = await package.FindToolWindowAsync(typeof(OutputToolWindow), 0, true, package.DisposalToken); |
112 | | - |
113 | | - if ((null == window) || (null == window.Frame)) |
114 | | - { |
115 | | - throw new NotSupportedException($"Cannot create '{Vsix.Name}' output window"); |
116 | | - } |
117 | | - }); |
| 107 | + throw new NotSupportedException($"Cannot create '{Vsix.Name}' output window"); |
| 108 | + } |
118 | 109 |
|
119 | 110 | return window; |
120 | 111 | } |
|
0 commit comments