public StateObjClass(frmWaitingTime frmWaiting) { _frmWaiting = frmWaiting; _timerReference = new Timer(); _timerReference.Tick += (sender, e) => { OnTimedEvent(this); }; _timerReference.Interval = 1000; _timerReference.Enabled = true; _timerReference.Start(); }
public static void InvokeIfRequired(this frmWaitingTime mForm, Action <frmWaitingTime> action) { if (mForm.InvokeRequired) { try { mForm.Invoke(new Action(() => action(mForm))); } catch (ObjectDisposedException) { // Ignore. Control is disposed cannot update the UI. } } else { action(mForm); } }
void StartAutomaticMode() { if (GR.Instance.BalanceSerialPort.SerialPortActive) { bool fillingCompleted; using (var frm = new frmAutomaticMode(this.ctrlGroupSelect1.SelectedGroup)) { frm.ShowDialog(); fillingCompleted = frm.FillingCompleted; } if (fillingCompleted) { using (var frm2 = new frmWaitingTime()) { frm2.ShowDialog(); } } } else { MessageBox.Show("Serial port not connected"); } }