@@ -47,7 +47,6 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
47
47
48
48
private CancellationTokenSource _updateSource ; // Used to cancel old query flows
49
49
private CancellationToken _updateToken ; // Used to avoid ObjectDisposedException of _updateSource.Token
50
- private readonly object _updateSourceLock = new ( ) ;
51
50
52
51
private ChannelWriter < ResultsForUpdate > _resultsUpdateChannelWriter ;
53
52
private Task _resultsViewUpdateTask ;
@@ -70,11 +69,8 @@ public MainViewModel()
70
69
_queryText = "" ;
71
70
_lastQuery = new Query ( ) ;
72
71
_ignoredQueryText = null ; // null as invalid value
73
- lock ( _updateSourceLock )
74
- {
75
- _updateSource = new CancellationTokenSource ( ) ;
76
- _updateToken = _updateSource . Token ;
77
- }
72
+ _updateSource = new CancellationTokenSource ( ) ;
73
+ _updateToken = _updateSource . Token ;
78
74
79
75
Settings = Ioc . Default . GetRequiredService < Settings > ( ) ;
80
76
Settings . PropertyChanged += ( _ , args ) =>
@@ -1244,10 +1240,7 @@ private static List<Result> GetHistoryItems(IEnumerable<HistoryItem> historyItem
1244
1240
1245
1241
private async Task QueryResultsAsync ( bool searchDelay , bool isReQuery = false , bool reSelect = true )
1246
1242
{
1247
- lock ( _updateSourceLock )
1248
- {
1249
- _updateSource . Cancel ( ) ;
1250
- }
1243
+ _updateSource ? . Cancel ( ) ;
1251
1244
1252
1245
App . API . LogDebug ( ClassName , $ "Start query with text: <{ QueryText } >") ;
1253
1246
@@ -1275,12 +1268,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
1275
1268
1276
1269
var isHomeQuery = query . RawQuery == string . Empty ;
1277
1270
1278
- lock ( _updateSourceLock )
1279
- {
1280
- _updateSource . Dispose ( ) ; // Dispose old update source to fix possible cancellation issue
1281
- _updateSource = new CancellationTokenSource ( ) ;
1282
- _updateToken = _updateSource . Token ;
1283
- }
1271
+ _updateSource ? . Dispose ( ) ; // Dispose old update source to fix possible cancellation issue
1272
+ _updateSource = new CancellationTokenSource ( ) ;
1273
+ _updateToken = _updateSource . Token ;
1284
1274
1285
1275
ProgressBarVisibility = Visibility . Hidden ;
1286
1276
_isQueryRunning = true ;
@@ -1898,10 +1888,7 @@ protected virtual void Dispose(bool disposing)
1898
1888
{
1899
1889
if ( disposing )
1900
1890
{
1901
- lock ( _updateSourceLock )
1902
- {
1903
- _updateSource ? . Dispose ( ) ;
1904
- }
1891
+ _updateSource ? . Dispose ( ) ;
1905
1892
_resultsUpdateChannelWriter ? . Complete ( ) ;
1906
1893
if ( _resultsViewUpdateTask ? . IsCompleted == true )
1907
1894
{
0 commit comments