private void SetToDefault() { // InvokeRequired required compares the thread ID of the // calling thread to the thread ID of the creating thread. // If these threads are different, it returns true. try { if (this.InvokeRequired) { var d = new VoidArgReturningVoidDelegate(SetToDefault); this.Invoke(d, new object[] { }); } else { this.btnExecute.Enabled = true; this.btnExecute.Text = "Execute"; this.btnRegister.Enabled = true; SetDetectionCheck(true); this.StablirizationCheck.Enabled = true; this.ComPortName.Enabled = true; this.isConnected = false; this.isExecute = false; this.isExecuting = false; this.isRegistExecute = false; this.isConnectRequest = false; } } catch { } }
private void ShowClientsNames() { if (tbClients.InvokeRequired) { VoidArgReturningVoidDelegate d = new VoidArgReturningVoidDelegate(ShowClientsNames); Invoke(d); } else { tbClients.Text = ""; for (int i = 0; i < clients.Count; i++) { tbClients.AppendText(clients[i].Name + "\n"); } } }