Optimization and Improvement.

Changed callback from synchronous Action<bool, string> to asynchronous Func<bool, string, Task>
This commit is contained in:
2dust
2025-08-29 11:53:30 +08:00
parent da28c639b3
commit a108eaf34b
2 changed files with 24 additions and 30 deletions
@@ -15,7 +15,7 @@ public class DownloadService
private static readonly string _tag = "DownloadService";
public async Task<int> DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout, Action<bool, string> updateFunc)
public async Task<int> DownloadDataAsync(string url, WebProxy webProxy, int downloadTimeout, Func<bool, string, Task> updateFunc)
{
try
{
@@ -31,10 +31,10 @@ public class DownloadService
}
catch (Exception ex)
{
updateFunc?.Invoke(false, ex.Message);
await updateFunc?.Invoke(false, ex.Message);
if (ex.InnerException != null)
{
updateFunc?.Invoke(false, ex.InnerException.Message);
await updateFunc?.Invoke(false, ex.InnerException.Message);
}
}
return 0;