@@ -50,8 +50,7 @@ public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, I
5050 readonly ReactiveCommand < Unit > showPullRequests ;
5151 readonly ReactiveCommand < object > openInBrowser ;
5252 readonly ReactiveCommand < object > help ;
53- readonly SemaphoreSlim initializing = new SemaphoreSlim ( 1 ) ;
54- bool initialized ;
53+ Task initializeTask ;
5554 IViewModel content ;
5655 ILocalRepositoryModel localRepository ;
5756 string searchQuery ;
@@ -207,34 +206,9 @@ public void Dispose()
207206 }
208207
209208 /// <inheritdoc/>
210- public async Task InitializeAsync ( IServiceProvider paneServiceProvider )
209+ public Task InitializeAsync ( IServiceProvider paneServiceProvider )
211210 {
212- await initializing . WaitAsync ( ) ;
213- if ( initialized ) return ;
214-
215- try
216- {
217- await UpdateContent ( teamExplorerContext . ActiveRepository ) ;
218- teamExplorerContext . WhenAnyValue ( x => x . ActiveRepository )
219- . Skip ( 1 )
220- . ObserveOn ( RxApp . MainThreadScheduler )
221- . Subscribe ( x => UpdateContent ( x ) . Forget ( ) ) ;
222-
223- connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateContent ( LocalRepository ) . Forget ( ) ;
224-
225- var menuService = ( IMenuCommandService ) paneServiceProvider . GetService ( typeof ( IMenuCommandService ) ) ;
226- BindNavigatorCommand ( menuService , PkgCmdIDList . pullRequestCommand , showPullRequests ) ;
227- BindNavigatorCommand ( menuService , PkgCmdIDList . backCommand , navigator . NavigateBack ) ;
228- BindNavigatorCommand ( menuService , PkgCmdIDList . forwardCommand , navigator . NavigateForward ) ;
229- BindNavigatorCommand ( menuService , PkgCmdIDList . refreshCommand , refresh ) ;
230- BindNavigatorCommand ( menuService , PkgCmdIDList . githubCommand , openInBrowser ) ;
231- BindNavigatorCommand ( menuService , PkgCmdIDList . helpCommand , help ) ;
232- }
233- finally
234- {
235- initialized = true ;
236- initializing . Release ( ) ;
237- }
211+ return initializeTask = initializeTask ?? CreateInitializeTask ( paneServiceProvider ) ;
238212 }
239213
240214 /// <inheritdoc/>
@@ -308,6 +282,25 @@ public Task ShowPullRequest(string owner, string repo, int number)
308282 x => x . RemoteRepositoryOwner == owner && x . LocalRepository . Name == repo && x . Number == number ) ;
309283 }
310284
285+ async Task CreateInitializeTask ( IServiceProvider paneServiceProvider )
286+ {
287+ await UpdateContent ( teamExplorerContext . ActiveRepository ) ;
288+ teamExplorerContext . WhenAnyValue ( x => x . ActiveRepository )
289+ . Skip ( 1 )
290+ . ObserveOn ( RxApp . MainThreadScheduler )
291+ . Subscribe ( x => UpdateContent ( x ) . Forget ( ) ) ;
292+
293+ connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateContent ( LocalRepository ) . Forget ( ) ;
294+
295+ var menuService = ( IMenuCommandService ) paneServiceProvider . GetService ( typeof ( IMenuCommandService ) ) ;
296+ BindNavigatorCommand ( menuService , PkgCmdIDList . pullRequestCommand , showPullRequests ) ;
297+ BindNavigatorCommand ( menuService , PkgCmdIDList . backCommand , navigator . NavigateBack ) ;
298+ BindNavigatorCommand ( menuService , PkgCmdIDList . forwardCommand , navigator . NavigateForward ) ;
299+ BindNavigatorCommand ( menuService , PkgCmdIDList . refreshCommand , refresh ) ;
300+ BindNavigatorCommand ( menuService , PkgCmdIDList . githubCommand , openInBrowser ) ;
301+ BindNavigatorCommand ( menuService , PkgCmdIDList . helpCommand , help ) ;
302+ }
303+
311304 OleMenuCommand BindNavigatorCommand < T > ( IMenuCommandService menu , int commandId , ReactiveCommand < T > command )
312305 {
313306 Guard . ArgumentNotNull ( menu , nameof ( menu ) ) ;
0 commit comments