This commit is contained in:
Administrator committed 2026-05-19 01:34:41 +08:00
commit 321e7d84c2
6 files changed
+60 -33

No files matched your search

+16 -3
View File
@@ -78,7 +78,10 @@ namespace SunlightAggregationTerminal.Class
}
catch (Exception ex)
{
await Application.Current!.Windows[0].Page!.DisplayAlertAsync("错误", ex.Message.ToString(), "是");
MainThread.BeginInvokeOnMainThread(() =>
{
Application.Current!.Windows[0].Page!.DisplayAlertAsync("错误", ex.Message.ToString(), "是");
});
}
finally
{
@@ -171,7 +174,12 @@ namespace SunlightAggregationTerminal.Class
}
}
catch (Exception ex) { Application.Current!.Windows[0].Page!.DisplayAlertAsync("", ex.Message.ToString(), "是"); }
catch (Exception ex) {
MainThread.BeginInvokeOnMainThread(() =>
{
Application.Current!.Windows[0].Page!.DisplayAlertAsync("", ex.Message.ToString(), "是");
});
}
return EasyTask.CompletedTask;
};
@@ -180,6 +188,7 @@ namespace SunlightAggregationTerminal.Class
try
{
await tcpClient.SetupAsync(new TouchSocketConfig()
.SetSingleStreamDataHandlingAdapter(() => new PeriodPackageAdapter())//以超时周期和包
.SetRemoteIPHost(ip)
.ConfigurePlugins(a =>
{
@@ -188,11 +197,15 @@ namespace SunlightAggregationTerminal.Class
options.PollingInterval = TimeSpan.FromSeconds(5);
});
}));
await tcpClient.ConnectAsync();//调用连接,当连接不成功时,会抛出异常。
}
catch (Exception ex)
{
await Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是");
MainThread.BeginInvokeOnMainThread(() =>
{
Application.Current!.Windows[0].Page!.DisplayAlertAsync("网络错误", ex.Message.ToString(), "是");
});
}
}
}