private void startMainHMI() { if (this.button1.InvokeRequired) //this is not the UI thread { startMainHMICallback d = new startMainHMICallback(startMainHMI); Invoke(d, new object[] { }); } else { MainHMI hmi = new MainHMI(); hmi.Station_ipAddress = ipAddressControl1.Text; hmi.ConnectToPLC(); hmi.Show(); this.Hide(); hmi.Closed += (s, args) => this.Close(); } }
private void startMainHMI() { bool endLoop = false; while (!endLoop) { endLoop = true; for (int i = 0; i < 5; i++) { if (!threadFinished[i]) { endLoop = false; } } Thread.Sleep(500); } if (this.button1.InvokeRequired) //this is not the UI thread { startMainHMICallback d = new startMainHMICallback(startMainHMI); Invoke(d, new object[] { }); } else { MainView hmi = new MainView(); hmi.modbusClients = modbusClients; hmi.stationIP = this.stationIP; hmi.startVariables(); hmi.startTimer(); hmi.Show(); this.Hide(); hmi.Closed += (s, args) => this.Close(); } }