This commit is contained in:
Administrator authored and sc committed 2026-06-21 18:39:59 +08:00
commit a72383e422
6 files changed
+21 -38

No files matched your search

+1 -29
View File
@@ -105,7 +105,6 @@ namespace SunlightAggregationTerminal.Class
{
await httpclient.ConnectAsync();
}
Dispose();
var dat = new DataReceived.Person()
{
@@ -147,40 +146,13 @@ namespace SunlightAggregationTerminal.Class
{
MainThread.BeginInvokeOnMainThread(() =>
{
Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是");
Application.Current!.Windows[0].Page!.DisplayAlertAsync("访问错误", ex.Message.ToString(), "是");
});
}
finally
{
//Start();
}
}
//倒计时5秒关闭http客户端
private static Timer? _timer;
private static bool _isDisposed = false;
private static void Start()
{
// 延迟30秒后执行一次,不自动循环
_timer = new Timer(Httpout, null, TimeSpan.FromSeconds(60), Timeout.InfiniteTimeSpan);
}
private static async void Dispose()
{
if (!_isDisposed)
{
_isDisposed = true;
_timer?.Dispose(); // 释放定时器资源
_timer = null;
}
}
private static async void Httpout(object? state)
{
if (httpclient.Online)
{
await httpclient.CloseAsync();
}
Dispose();
}
}
}