From 501633435942fa701c53e25ec0b074df0cbbe3df Mon Sep 17 00:00:00 2001 From: Jack251970 <1160210343@qq.com> Date: Thu, 9 Jan 2025 17:37:53 +0800 Subject: [PATCH] Avoid cancelling all pending requests on shared HttpClient instance --- .../Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs index f5399d53d..081f8d489 100644 --- a/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs +++ b/Plugins/Flow.Launcher.Plugin.PluginsManager/PluginsManager.cs @@ -153,7 +153,8 @@ namespace Flow.Launcher.Plugin.PluginsManager if (File.Exists(filePath)) File.Delete(filePath); - using var response = await HttpClient.GetAsync(plugin.UrlDownload, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false); + using var cts = new CancellationTokenSource(); + using var response = await HttpClient.GetAsync(plugin.UrlDownload, HttpCompletionOption.ResponseHeadersRead, cts.Token).ConfigureAwait(false); response.EnsureSuccessStatusCode(); @@ -166,7 +167,7 @@ namespace Flow.Launcher.Plugin.PluginsManager { if (prgBox != null) { - HttpClient.CancelPendingRequests(); + cts.Cancel(); downloadCancelled = true; } })) != null)