@@ -46,6 +46,8 @@ public sealed class GitHubPaneViewModel : ViewModelBase, IGitHubPaneViewModel, I
4646 readonly ReactiveCommand < Unit > refresh ;
4747 readonly ReactiveCommand < Unit > showPullRequests ;
4848 readonly ReactiveCommand < object > openInBrowser ;
49+ readonly SemaphoreSlim initializing = new SemaphoreSlim ( 1 ) ;
50+ bool initialized ;
4951 IViewModel content ;
5052 ILocalRepositoryModel localRepository ;
5153 string searchQuery ;
@@ -198,26 +200,37 @@ public void Dispose()
198200 /// <inheritdoc/>
199201 public async Task InitializeAsync ( IServiceProvider paneServiceProvider )
200202 {
201- await UpdateContent ( teamExplorerContext . ActiveRepository ) ;
202- teamExplorerContext . WhenAnyValue ( x => x . ActiveRepository )
203- . Skip ( 1 )
204- . ObserveOn ( RxApp . MainThreadScheduler )
205- . Subscribe ( x => UpdateContent ( x ) . Forget ( ) ) ;
206-
207- connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateContent ( LocalRepository ) . Forget ( ) ;
208-
209- BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . pullRequestCommand , showPullRequests ) ;
210- BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . backCommand , navigator . NavigateBack ) ;
211- BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . forwardCommand , navigator . NavigateForward ) ;
212- BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . refreshCommand , refresh ) ;
213- BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . githubCommand , openInBrowser ) ;
214-
215- paneServiceProvider . AddCommandHandler ( Guids . guidGitHubToolbarCmdSet , PkgCmdIDList . helpCommand ,
216- ( _ , __ ) =>
217- {
218- browser . OpenUrl ( new Uri ( GitHubUrls . Documentation ) ) ;
219- usageTracker . IncrementCounter ( x => x . NumberOfGitHubPaneHelpClicks ) . Forget ( ) ;
220- } ) ;
203+ await initializing . WaitAsync ( ) ;
204+ if ( initialized ) return ;
205+
206+ try
207+ {
208+ await UpdateContent ( teamExplorerContext . ActiveRepository ) ;
209+ teamExplorerContext . WhenAnyValue ( x => x . ActiveRepository )
210+ . Skip ( 1 )
211+ . ObserveOn ( RxApp . MainThreadScheduler )
212+ . Subscribe ( x => UpdateContent ( x ) . Forget ( ) ) ;
213+
214+ connectionManager . Connections . CollectionChanged += ( _ , __ ) => UpdateContent ( LocalRepository ) . Forget ( ) ;
215+
216+ BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . pullRequestCommand , showPullRequests ) ;
217+ BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . backCommand , navigator . NavigateBack ) ;
218+ BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . forwardCommand , navigator . NavigateForward ) ;
219+ BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . refreshCommand , refresh ) ;
220+ BindNavigatorCommand ( paneServiceProvider , PkgCmdIDList . githubCommand , openInBrowser ) ;
221+
222+ paneServiceProvider . AddCommandHandler ( Guids . guidGitHubToolbarCmdSet , PkgCmdIDList . helpCommand ,
223+ ( _ , __ ) =>
224+ {
225+ browser . OpenUrl ( new Uri ( GitHubUrls . Documentation ) ) ;
226+ usageTracker . IncrementCounter ( x => x . NumberOfGitHubPaneHelpClicks ) . Forget ( ) ;
227+ } ) ;
228+ }
229+ finally
230+ {
231+ initialized = true ;
232+ initializing . Release ( ) ;
233+ }
221234 }
222235
223236 /// <inheritdoc/>
0 commit comments