public void Compute(object sender, EventArgs e) { try { var para = new BoeingParameterValidator(elements).Validate(); if (!CheckWeight(para)) { return; } var report = new LandingReportGenerator((BoeingPerfTable)acPerf.Item, para) .GetReport(); var text = report.ToString((LengthUnit)elements.lengthUnit.SelectedIndex); // To center the text in the richTxtBox elements.result.Text = text.ShiftToRight(14); CalculationCompleted?.Invoke(this, EventArgs.Empty); elements.result.ForeColor = Color.Black; } catch (InvalidUserInputException ex) { parentControl.ShowWarning(ex.Message); } catch (RunwayTooShortException) { parentControl.ShowWarning("Runway length is insufficient for landing."); } }
public void Compute(object sender, EventArgs e) { try { var para = new BoeingParameterValidator(elements).Validate(); var table = (BoeingPerfTable)acPerf.Item; if (!CheckWeight(para)) { return; } var tempUnit = (TemperatureUnit)elements.TempUnit.SelectedIndex; var tempIncrement = tempUnit == TemperatureUnit.Celsius ? 1.0 : 2.0 / 1.8; var report = new TOReportGenerator(table, para).TakeOffReport(tempIncrement); var text = report.ToString(tempUnit, (LengthUnit)elements.lengthUnit.SelectedIndex); // To center the text in the richTxtBox elements.Result.Text = text.ShiftToRight(15); CalculationCompleted?.Invoke(this, EventArgs.Empty); elements.Result.ForeColor = Color.Black; } catch (InvalidUserInputException ex) { parentControl.ShowWarning(ex.Message); } catch (RunwayTooShortException) { parentControl.ShowWarning("Runway length is insufficient for takeoff."); } catch (PoorClimbPerformanceException) { parentControl.ShowWarning("Aircraft too heavy to meet " + "climb performance requirement."); } }
public void Calculate() { while (ShouldICalculate) { int A = 0, B = 0, Count = 0; while (!(A < B)) { Random random = new Random(); A = random.Next(2, 10000); B = random.Next(A, 10000); } for (int i = A; i <= B; ++i) { if (!ShouldICalculate) { return; } if (IsSphenic(i)) { ++Count; } } CalculationCompleted?.Invoke(A, B, Count); if (!ShouldICalculate) { return; } Thread.Sleep(TimeToSleep); } }
public void Handle(CalculationCompleted eventData) { calcEnded = true; trigger.Set(); }
public void OnCalculationComplete() { CalculationCompleted?.Invoke(this, new EventArgs()); }