mirror of
https://github.com/Flow-Launcher/Flow.Launcher.git
synced 2026-03-11 08:54:32 +00:00
Use static HttpClient instance for heavy load issue
This commit is contained in:
parent
cc0fb66b22
commit
bc84910e56
1 changed files with 5 additions and 4 deletions
|
|
@ -17,7 +17,9 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
internal class PluginsManager
|
||||
{
|
||||
const string zip = "zip";
|
||||
private static readonly HttpClient HttpClient = new();
|
||||
|
||||
private const string zip = "zip";
|
||||
|
||||
private PluginInitContext Context { get; set; }
|
||||
|
||||
|
|
@ -151,8 +153,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
if (File.Exists(filePath))
|
||||
File.Delete(filePath);
|
||||
|
||||
using var httpClient = new HttpClient();
|
||||
using var response = await httpClient.GetAsync(plugin.UrlDownload, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
|
||||
using var response = await HttpClient.GetAsync(plugin.UrlDownload, HttpCompletionOption.ResponseHeadersRead).ConfigureAwait(false);
|
||||
|
||||
response.EnsureSuccessStatusCode();
|
||||
|
||||
|
|
@ -165,7 +166,7 @@ namespace Flow.Launcher.Plugin.PluginsManager
|
|||
{
|
||||
if (prgBox != null)
|
||||
{
|
||||
httpClient.CancelPendingRequests();
|
||||
HttpClient.CancelPendingRequests();
|
||||
downloadCancelled = true;
|
||||
prgBox = null;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue