@@ -55,8 +55,19 @@ public void Refresh()
5555
5656 public async Task UpdateStatusAsync ( bool force , CancellationToken ? token )
5757 {
58- foreach ( var node in Preferences . Instance . RepositoryNodes )
58+ if ( _isUpdatingStatus )
59+ return ;
60+
61+ _isUpdatingStatus = true ;
62+
63+ // avoid collection was modified while enumerating.
64+ var nodes = new List < RepositoryNode > ( ) ;
65+ nodes . AddRange ( Preferences . Instance . RepositoryNodes ) ;
66+
67+ foreach ( var node in nodes )
5968 await node . UpdateStatusAsync ( force , token ) ;
69+
70+ _isUpdatingStatus = false ;
6071 }
6172
6273 public void ToggleNodeIsExpanded ( RepositoryNode node )
@@ -130,9 +141,11 @@ public void InitRepository(string path, RepositoryNode parent, string reason)
130141 activePage . Popup = new Init ( activePage . Node . Id , path , parent , reason ) ;
131142 }
132143
133- public void AddRepository ( string path , RepositoryNode parent , bool moveNode , bool open )
144+ public async Task AddRepositoryAsync ( string path , RepositoryNode parent , bool moveNode , bool open )
134145 {
135146 var node = Preferences . Instance . FindOrAddNodeByRepositoryPath ( path , parent , moveNode ) ;
147+ await node . UpdateStatusAsync ( false , null ) ;
148+
136149 if ( open )
137150 node . Open ( ) ;
138151 }
@@ -277,5 +290,6 @@ private void MakeTreeRows(List<RepositoryNode> rows, List<RepositoryNode> nodes,
277290 }
278291
279292 private string _searchFilter = string . Empty ;
293+ private bool _isUpdatingStatus = false ;
280294 }
281295}
0 commit comments