* Fix async

* Fix async for statistics

* Try fix pac async

* Fix
This commit is contained in:
DHR60
2026-09-26 03:08:36 +00:00
committed by GitHub
parent fa1e201c76
commit 93d8174dbe
9 changed files with 153 additions and 167 deletions
+7 -3
View File
@@ -22,7 +22,7 @@ public class HttpClientHelper
this.httpClient = httpClient;
}
public async Task<string?> TryGetAsync(string url)
public async Task<string?> TryGetAsync(string url, CancellationToken cancellationToken = default)
{
if (url.IsNullOrEmpty())
{
@@ -31,8 +31,12 @@ public class HttpClientHelper
try
{
var response = await httpClient.GetAsync(url);
return await response.Content.ReadAsStringAsync();
var response = await httpClient.GetAsync(url, cancellationToken);
return await response.Content.ReadAsStringAsync(cancellationToken);
}
catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
{
throw;
}
catch
{
+20 -7
View File
@@ -75,15 +75,28 @@ public sealed class SQLiteHelper
public async Task DisposeDbConnectionAsync()
{
await Task.Factory.StartNew(() =>
await Task.Run(() =>
{
_db?.Close();
_db?.Dispose();
_db = null;
try
{
_db?.Close();
_db?.Dispose();
}
finally
{
_db = null;
}
_dbAsync?.GetConnection()?.Close();
_dbAsync?.GetConnection()?.Dispose();
_dbAsync = null;
try
{
var conn = _dbAsync?.GetConnection();
conn?.Close();
conn?.Dispose();
}
finally
{
_dbAsync = null;
}
});
}
}