mirror of
https://github.com/2dust/v2rayN.git
synced 2025-04-30 12:18:51 +00:00
Update DownloadService.cs
AI-optimized code
This commit is contained in:
parent
c374b8565b
commit
a0af4fb30c
1 changed files with 3 additions and 13 deletions
|
@ -23,14 +23,7 @@ namespace ServiceLib.Services
|
||||||
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
SetSecurityProtocol(AppHandler.Instance.Config.GuiItem.EnableSecurityProtocolTls13);
|
||||||
|
|
||||||
var progress = new Progress<string>();
|
var progress = new Progress<string>();
|
||||||
progress.ProgressChanged += (sender, value) =>
|
progress.ProgressChanged += (sender, value) => updateFunc?.Invoke(false, $"{value}");
|
||||||
{
|
|
||||||
if (updateFunc != null)
|
|
||||||
{
|
|
||||||
string msg = $"{value}";
|
|
||||||
updateFunc?.Invoke(false, msg);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
await DownloaderHelper.Instance.DownloadDataAsync4Speed(webProxy,
|
await DownloaderHelper.Instance.DownloadDataAsync4Speed(webProxy,
|
||||||
url,
|
url,
|
||||||
|
@ -56,10 +49,7 @@ namespace ServiceLib.Services
|
||||||
UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}"));
|
UpdateCompleted?.Invoke(this, new RetResult(false, $"{ResUI.Downloading} {url}"));
|
||||||
|
|
||||||
var progress = new Progress<double>();
|
var progress = new Progress<double>();
|
||||||
progress.ProgressChanged += (sender, value) =>
|
progress.ProgressChanged += (sender, value) => UpdateCompleted?.Invoke(this, new RetResult(value > 100, $"...{value}%"));
|
||||||
{
|
|
||||||
UpdateCompleted?.Invoke(this, new RetResult(value > 100, $"...{value}%"));
|
|
||||||
};
|
|
||||||
|
|
||||||
var webProxy = await GetWebProxy(blProxy);
|
var webProxy = await GetWebProxy(blProxy);
|
||||||
await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
|
await DownloaderHelper.Instance.DownloadFileAsync(webProxy,
|
||||||
|
@ -263,7 +253,7 @@ namespace ServiceLib.Services
|
||||||
for (var i = 0; i < 2; i++)
|
for (var i = 0; i < 2; i++)
|
||||||
{
|
{
|
||||||
var timer = Stopwatch.StartNew();
|
var timer = Stopwatch.StartNew();
|
||||||
await client.GetAsync(url, cts.Token);
|
await client.GetAsync(url, cts.Token).ConfigureAwait(false);
|
||||||
timer.Stop();
|
timer.Stop();
|
||||||
oneTime.Add((int)timer.Elapsed.TotalMilliseconds);
|
oneTime.Add((int)timer.Elapsed.TotalMilliseconds);
|
||||||
await Task.Delay(100);
|
await Task.Delay(100);
|
||||||
|
|
Loading…
Reference in a new issue