private void ThreadPoolCheckVersion(object obj) { System.Threading.Thread.Sleep(100); HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467); HslCommunication.OperateResult <HslCommunication.NetHandle, string> read = simplifyClient.ReadCustomerFromServer(1, HslCommunication.BasicFramework.SoftBasic.FrameworkVersion.ToString( )); if (read.IsSuccess) { HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content2); if (version > HslCommunication.BasicFramework.SoftBasic.FrameworkVersion) { // 有更新 Invoke(new Action(() => { if (MessageBox.Show("服务器有新版本:" + read.Content2 + Environment.NewLine + "是否启动更新?", "检测到更新", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { System.Diagnostics.Process.Start(Application.StartupPath + "\\软件自动更新.exe"); System.Threading.Thread.Sleep(50); Close( ); } catch (Exception ex) { MessageBox.Show("更新软件丢失,无法启动更新: " + ex.Message); } } })); } } }
private void ThreadPoolCheckVersion(object obj) { System.Threading.Thread.Sleep(100); mqttClient = new HslCommunication.MQTT.MqttClient(new HslCommunication.MQTT.MqttConnectionOptions( ) { IpAddress = "118.24.36.220", Port = 1883, ClientId = "HslDemo" }); mqttClient.ConnectServer( ); HslCommunication.Enthernet.NetSimplifyClient simplifyClient = new HslCommunication.Enthernet.NetSimplifyClient("118.24.36.220", 18467); HslCommunication.OperateResult <HslCommunication.NetHandle, string> read = simplifyClient.ReadCustomerFromServer(1, HslCommunication.BasicFramework.SoftBasic.FrameworkVersion.ToString( )); if (read.IsSuccess) { HslCommunication.BasicFramework.SystemVersion version = new HslCommunication.BasicFramework.SystemVersion(read.Content2); if (version > HslCommunication.BasicFramework.SoftBasic.FrameworkVersion) { // 有更新 Invoke(new Action(() => { if (MessageBox.Show("New version on server:" + read.Content2 + Environment.NewLine + " Start update?", "Version Check", MessageBoxButtons.YesNo) == DialogResult.Yes) { try { System.Diagnostics.Process.Start(Application.StartupPath + "\\软件自动更新.exe"); System.Threading.Thread.Sleep(50); Close( ); } catch (Exception ex) { MessageBox.Show("更新软件丢失,无法启动更新: " + ex.Message); } } })); } } try { cur = Process.GetCurrentProcess( ); curpcp = new PerformanceCounter("Process", "Working Set - Private", cur.ProcessName); } catch { } }