Revert "Add update source lock"

This reverts commit 265fd9c868.
This commit is contained in:
Jack251970 2025-05-06 14:14:10 +08:00
parent 265fd9c868
commit b156afed0b

View file

@ -47,7 +47,6 @@ namespace Flow.Launcher.ViewModel
private CancellationTokenSource _updateSource; // Used to cancel old query flows
private CancellationToken _updateToken; // Used to avoid ObjectDisposedException of _updateSource.Token
private readonly object _updateSourceLock = new();
private ChannelWriter<ResultsForUpdate> _resultsUpdateChannelWriter;
private Task _resultsViewUpdateTask;
@ -70,11 +69,8 @@ namespace Flow.Launcher.ViewModel
_queryText = "";
_lastQuery = new Query();
_ignoredQueryText = null; // null as invalid value
lock (_updateSourceLock)
{
_updateSource = new CancellationTokenSource();
_updateToken = _updateSource.Token;
}
_updateSource = new CancellationTokenSource();
_updateToken = _updateSource.Token;
Settings = Ioc.Default.GetRequiredService<Settings>();
Settings.PropertyChanged += (_, args) =>
@ -1244,10 +1240,7 @@ namespace Flow.Launcher.ViewModel
private async Task QueryResultsAsync(bool searchDelay, bool isReQuery = false, bool reSelect = true)
{
lock (_updateSourceLock)
{
_updateSource.Cancel();
}
_updateSource?.Cancel();
App.API.LogDebug(ClassName, $"Start query with text: <{QueryText}>");
@ -1275,12 +1268,9 @@ namespace Flow.Launcher.ViewModel
var isHomeQuery = query.RawQuery == string.Empty;
lock (_updateSourceLock)
{
_updateSource.Dispose(); // Dispose old update source to fix possible cancellation issue
_updateSource = new CancellationTokenSource();
_updateToken = _updateSource.Token;
}
_updateSource?.Dispose(); // Dispose old update source to fix possible cancellation issue
_updateSource = new CancellationTokenSource();
_updateToken = _updateSource.Token;
ProgressBarVisibility = Visibility.Hidden;
_isQueryRunning = true;
@ -1898,10 +1888,7 @@ namespace Flow.Launcher.ViewModel
{
if (disposing)
{
lock (_updateSourceLock)
{
_updateSource?.Dispose();
}
_updateSource?.Dispose();
_resultsUpdateChannelWriter?.Complete();
if (_resultsViewUpdateTask?.IsCompleted == true)
{