Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightAggregationTerminal
This commit is contained in:
commit
a72383e422
6 files changed
+21
-38
No files matched your search
+1
-29
@@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user