Skip to content

Commit b156afe

Browse files
committed
Revert "Add update source lock"
This reverts commit 265fd9c.
1 parent 265fd9c commit b156afe

File tree

1 file changed

+7
-20
lines changed

1 file changed

+7
-20
lines changed

Flow.Launcher/ViewModel/MainViewModel.cs

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ public partial class MainViewModel : BaseModel, ISavable, IDisposable
4747

4848
private CancellationTokenSource _updateSource; // Used to cancel old query flows
4949
private CancellationToken _updateToken; // Used to avoid ObjectDisposedException of _updateSource.Token
50-
private readonly object _updateSourceLock = new();
5150

5251
private ChannelWriter<ResultsForUpdate> _resultsUpdateChannelWriter;
5352
private Task _resultsViewUpdateTask;
@@ -70,11 +69,8 @@ public MainViewModel()
7069
_queryText = "";
7170
_lastQuery = new Query();
7271
_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;
7874

7975
Settings = Ioc.Default.GetRequiredService<Settings>();
8076
Settings.PropertyChanged += (_, args) =>
@@ -1244,10 +1240,7 @@ private static List<Result> GetHistoryItems(IEnumerable<HistoryItem> historyItem
12441240

12451241
private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, bool reSelect = true)
12461242
{
1247-
lock (_updateSourceLock)
1248-
{
1249-
_updateSource.Cancel();
1250-
}
1243+
_updateSource?.Cancel();
12511244

12521245
App.API.LogDebug(ClassName, $"Start query with text: <{QueryText}>");
12531246

@@ -1275,12 +1268,9 @@ private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, b
12751268

12761269
var isHomeQuery = query.RawQuery == string.Empty;
12771270

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;
12841274

12851275
ProgressBarVisibility = Visibility.Hidden;
12861276
_isQueryRunning = true;
@@ -1898,10 +1888,7 @@ protected virtual void Dispose(bool disposing)
18981888
{
18991889
if (disposing)
19001890
{
1901-
lock (_updateSourceLock)
1902-
{
1903-
_updateSource?.Dispose();
1904-
}
1891+
_updateSource?.Dispose();
19051892
_resultsUpdateChannelWriter?.Complete();
19061893
if (_resultsViewUpdateTask?.IsCompleted == true)
19071894
{

0 commit comments

Comments
 (0)