@@ -44,7 +44,6 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
4444 private readonly TopMostRecord _topMostRecord ;
4545
4646 private CancellationTokenSource _updateSource ; // Used to cancel old query flows
47- private readonly SemaphoreSlim _updateLock = new ( 1 , 6 ) ; // Used to ensure up to six update flows
4847
4948 private ChannelWriter < ResultsForUpdate > _resultsUpdateChannelWriter ;
5049 private Task _resultsViewUpdateTask ;
@@ -1222,41 +1221,20 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12221221 {
12231222 Infrastructure . Logger . Log . Debug ( ClassName , $ "Query null for QueryText") ;
12241223
1225- // Hide and clear results fast because results are already invalid although query is still running
1224+ // Hide and clear results again because running query may show and add some results
12261225 Results . Visibility = Visibility . Collapsed ;
12271226 Results . Clear ( ) ;
12281227
1229- // Hide progress bar because running query is already invalid
1230- ProgressBarVisibility = Visibility . Hidden ;
1228+ // Reset plugin icon
1229+ PluginIconPath = null ;
1230+ PluginIconSource = null ;
1231+ SearchIconVisibility = Visibility . Visible ;
12311232
1232- // Wait last query to be canceled and then reset UI elements
1233- await _updateLock . WaitAsync ( CancellationToken . None ) ;
1234- try
1235- {
1236- Infrastructure . Logger . Log . Debug ( ClassName , $ "Clear for QueryText") ;
1237-
1238- // Hide and clear results again because running query may show and add some results
1239- Results . Visibility = Visibility . Collapsed ;
1240- Results . Clear ( ) ;
1241-
1242- // Reset plugin icon
1243- PluginIconPath = null ;
1244- PluginIconSource = null ;
1245- SearchIconVisibility = Visibility . Visible ;
1246-
1247- // Hide progress bar again because running query may set this to visible
1248- ProgressBarVisibility = Visibility . Hidden ;
1249- }
1250- finally
1251- {
1252- _updateLock . Release ( ) ;
1253- }
1233+ // Hide progress bar again because running query may set this to visible
1234+ ProgressBarVisibility = Visibility . Hidden ;
12541235 return ;
12551236 }
12561237
1257- Infrastructure . Logger . Log . Debug ( ClassName , $ "Wait for QueryText: { query . RawQuery } ") ;
1258-
1259- await _updateLock . WaitAsync ( CancellationToken . None ) ;
12601238 try
12611239 {
12621240 // Check if the query has changed because query can be changed so fast that
@@ -1379,9 +1357,6 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
13791357 Infrastructure . Logger . Log . Debug ( ClassName , $ "Query return for QueryText: { query . RawQuery } ") ;
13801358 // this make sures running query is null even if the query is canceled
13811359 _runningQuery = null ;
1382-
1383- // release the lock so that other query can be executed
1384- _updateLock . Release ( ) ;
13851360 }
13861361
13871362 // Local function
@@ -1865,7 +1840,6 @@ protected virtual void Dispose(bool disposing)
18651840 {
18661841 _resultsViewUpdateTask . Dispose ( ) ;
18671842 }
1868- _updateLock ? . Dispose ( ) ;
18691843 _disposed = true ;
18701844 }
18711845 }
0 commit comments