/// <summary> /// The work handler function for the background worker. Displays /// the calibration form as a dialog /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as Worker; calibrationForm = new CalibrationForm { Caption = worker.Caption, Prompt = worker.Prompt, SourceActuator = SourceActuator, Timeout = worker.Timeout, EnableConfigure = worker.EnableConfigure }; Windows.SetWindowPosition(calibrationForm, worker.Position); _formCreatedEvent.Set(); calibrationForm.ShowDialog(); calibrationForm.Dispose(); }
/// <summary> /// Closes the calibration form /// </summary> private void closeCalibrationForm() { try { if (calibrationForm != null) { calibrationForm.Dismiss(); calibrationForm = null; } if (_bgWorker != null) { _bgWorker.CancelAsync(); _bgWorker.Dispose(); _bgWorker = null; } } catch { } }
/// <summary> /// The work handler function for the background worker. Displays /// the calibration form as a dialog /// </summary> /// <param name="sender">event sender</param> /// <param name="e">event args</param> private void bgWorker_DoWork(object sender, DoWorkEventArgs e) { var worker = sender as Worker; calibrationForm = new CalibrationForm { Caption = worker.Caption, Prompt = worker.Prompt, SourceActuator = SourceActuator, Timeout = worker.Timeout, EnableConfigure = worker.EnableConfigure, ButtonText = worker.ButtonText }; Windows.SetWindowPosition(calibrationForm, worker.Position); _formCreatedEvent.Set(); if (calibrationForm != null) { Log.Debug("Calling calibrationform.ShowDialog"); DialogResult result = calibrationForm.ShowDialog(); Log.Debug("Result: " + result); // user closed the calibration form if (result == DialogResult.Cancel) { SourceActuator.OnCalibrationCanceled(); _calibrationDoneEvent.Set(); } } else { Log.Debug("calibration form IS NULL!!!"); } if (calibrationForm != null) { calibrationForm.Dispose(); calibrationForm = null; } }
/// <summary> /// Closes the calibration form /// </summary> private void closeCalibrationForm() { try { if (calibrationForm != null) { Log.Debug("Closing calibration form, calling Dismiss()"); calibrationForm.Dismiss(); calibrationForm = null; } if (_bgWorker != null) { _bgWorker.CancelAsync(); _bgWorker.Dispose(); _bgWorker = null; } } catch { } }